code wiki / _hdl_build / _pe_f64sinhcosh_test.nx

_pe_f64sinhcosh_test.nx source

↩ module page · 25 lines · 1337 B

1// AUTHORED BY THE NISHI BUILDER (pattern: MATH_KERNEL SINHCOSH test) -- invariant KATs. 2import "_pe_f64sinhcosh.nx" 3import "nx_syscalls.nx" 4func main() -> i64 { 5 var bad: i64 = 0 6 if nx_f64_sinh(0) != 0 { bad = bad + 1 } 7 if nx_f64_sinh(1 << 63) != (1 << 63) { bad = bad + 1 } 8 if nx_f64_cosh(0) != 4607182418800017408 { bad = bad + 1 } 9 if nx_f64_cosh(1 << 63) != 4607182418800017408 { bad = bad + 1 } 10 if nx_f64_sinh(0x7FF8000000000000) != 0x7FF8000000000000 { bad = bad + 1 } 11 if nx_f64_sinh(0x7FF0000000000000) != 0x7FF0000000000000 { bad = bad + 1 } 12 if nx_f64_sinh(0xFFF0000000000000) != 0xFFF0000000000000 { bad = bad + 1 } 13 if nx_f64_cosh(0xFFF0000000000000) != 0x7FF0000000000000 { bad = bad + 1 } 14 if nx_f64_sinh(0x4086340000000000) != 0x7FF0000000000000 { bad = bad + 1 } 15 if nx_f64_cosh(0x4086340000000000) != 0x7FF0000000000000 { bad = bad + 1 } 16 let pv: i64 = nx_f64_sinh(0x4000000000000000) 17 if nx_f64_sinh(0xC000000000000000) != (pv | (1 << 63)) { bad = bad + 1 } 18 if nx_f64_cosh(0xC000000000000000) != nx_f64_cosh(0x4000000000000000) { bad = bad + 1 } 19 let nl: *u8 = sys_mmap(4) 20 nl[0] = 10 21 if bad == 0 { sys_write(1, "SINHCOSH-TEST GREEN" as *u8, 19) } else { sys_write(1, "SINHCOSH-TEST RED" as *u8, 17) } 22 sys_write(1, nl, 1) 23 sys_exit(bad) 24 return bad 25}