path: root/lib/std/test
diff options
authorS. Gilles <>2018-02-27 22:54:18 -0500
committerOri Bernstein <>2018-02-27 21:22:14 -0800
commit19248d9673c0da5c189bf81e7c89a339cf99e405 (patch)
tree03242c3569c0d4a82362ae6edb9299bc9e9f0ee8 /lib/std/test
parentabb53670c906a115ba5b0cbf97fb9e5d165e94d3 (diff)
Adjust signs of fltbits functions
The fltXYbits and fltXYfrombits functions now return/take unsigned integers uniformly, allowing easier round-tripping. Unsigned was chosen to emphasize that the value of the result is probably unrelated to the floating-point value. The fltXYexplode and fltXYassem functions now return the mantissa (significand) unsigned, but the exponent signed. This reflects the allowed ranges represented by the encoding.
Diffstat (limited to 'lib/std/test')
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/std/test/fltbits.myr b/lib/std/test/fltbits.myr
index 4e64137..357d292 100644
--- a/lib/std/test/fltbits.myr
+++ b/lib/std/test/fltbits.myr
@@ -1,5 +1,17 @@
use std
+use testr
const main = {
- std.assert(std.isnan(std.flt64nan()), "isnan(nan) false\n")
+ [.name = "isnan", .fn = isnan01],
+ ][:])
+const isnan01 = {c
+ testr.check(c, std.isnan(std.flt64nan()), "std.flt64nan() should give a NaN")
+ testr.check(c, std.isnan(std.flt32nan()), "std.flt32nan() should give a NaN")
+ testr.check(c, std.isnan(std.flt64frombits(0xfff0000500000000ul)), "0xfff0000500000000 should be a NaN")
+ testr.check(c, !std.isnan(std.flt64frombits(0xfff0000000000000ul)), "Infinities should not be NaNs")