code wiki / _hdl_build / _pe_f64sincos_test.nx
_pe_f64sincos_test.nx source
↩ module page · 19 lines · 866 B
1// AUTHORED BY THE NISHI BUILDER (pattern: MATH_KERNEL SINCOS test) -- invariant KATs.
2import "_pe_f64sincos.nx"
3import "nx_syscalls.nx"
4func main() -> i64 {
5 var bad: i64 = 0
6 if nx_f64_sin(0) != 0 { bad = bad + 1 }
7 if nx_f64_sin(1 << 63) != (1 << 63) { bad = bad + 1 }
8 if nx_f64_cos(0) != 4607182418800017408 { bad = bad + 1 }
9 if nx_f64_cos(1 << 63) != 4607182418800017408 { bad = bad + 1 }
10 if nx_f64_sin(0x7FF0000000000000) != 0x7FF8000000000000 { bad = bad + 1 }
11 if nx_f64_cos(0x7FF8000000000000) != 0x7FF8000000000000 { bad = bad + 1 }
12 if nx_f64_sin(0x4140000000000000) != 0x7FF8000000000000 { bad = bad + 1 }
13 let nl: *u8 = sys_mmap(4)
14 nl[0] = 10
15 if bad == 0 { sys_write(1, "SINCOS-TEST GREEN" as *u8, 17) } else { sys_write(1, "SINCOS-TEST RED" as *u8, 15) }
16 sys_write(1, nl, 1)
17 sys_exit(bad)
18 return bad
19}