We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f999cb commit 0f60ea2Copy full SHA for 0f60ea2
compiler/tests-jsoo/test_nan.ml
@@ -0,0 +1,15 @@
1
+let none = Int64.float_of_bits 0x7ff0_1234_5678_90ABL
2
+
3
+let sign_mask = 0x8000_0000_0000_0000L
4
5
+let some x =
6
+ if Float.is_nan x
7
+ then if Int64.(logand (bits_of_float x) sign_mask = 0L) then nan else -.nan
8
+ else x
9
10
+let is_none t = Int64.equal (Int64.bits_of_float t) (Int64.bits_of_float none)
11
12
+let () =
13
+ assert (is_none none);
14
+ let l = [ nan; -.nan; 1.; -7.; infinity; neg_infinity; 0.; none ] in
15
+ List.iter (fun f -> assert (not (is_none (some f)))) l
0 commit comments