[MLton-commit] r5793

Matthew Fluet fluet at mlton.org
Thu Jul 26 18:04:57 PDT 2007


Regression test from Sean McLaughlin demonstrating incorrect CSE of fp operations in presence of rounding modes
----------------------------------------------------------------------

A   mlton/trunk/regression/ieee-real.ok
A   mlton/trunk/regression/ieee-real.sml

----------------------------------------------------------------------

Added: mlton/trunk/regression/ieee-real.ok
===================================================================
--- mlton/trunk/regression/ieee-real.ok	2007-07-26 04:01:03 UTC (rev 5792)
+++ mlton/trunk/regression/ieee-real.ok	2007-07-27 01:04:57 UTC (rev 5793)
@@ -0,0 +1,4 @@
+3FB9999999999999
+3FB999999999999A
+3FB999999999999A
+3FB9999999999999

Added: mlton/trunk/regression/ieee-real.sml
===================================================================
--- mlton/trunk/regression/ieee-real.sml	2007-07-26 04:01:03 UTC (rev 5792)
+++ mlton/trunk/regression/ieee-real.sml	2007-07-27 01:04:57 UTC (rev 5793)
@@ -0,0 +1,43 @@
+structure R = Real
+structure I = IEEEReal
+structure V = Word8Vector
+structure P = PackRealBig
+
+fun setRM mode =
+   (I.setRoundingMode mode;
+    if I.getRoundingMode () <> mode
+       then raise Fail "setRM"
+    else ())
+
+fun up() = setRM I.TO_POSINF
+fun down() = setRM I.TO_NEGINF
+fun near() = setRM I.TO_NEAREST
+fun zero() = setRM I.TO_ZERO
+
+  (*
+
+  61 digits of 1 / 10 in Mathematica
+
+  In[7]:= RealDigits[1 / 10,2,61]
+
+  Out[7]= {{1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0,
+               0, 1, 1, 0, 0, 1, 1, 0, 0, 1,
+               1, 0, 0, 1, 1, 0, 0, 1, 1, 0,
+               0, 1, 1, 0, 0, 1, 1, 0, 0, 1,
+               1, 0, 0, 1, 1, 0, 0, 1, 1, 0,
+               0, 1, 1, 0, 0, 1, 1, 0, 0, 1},-3}
+
+  *)
+
+
+val mtenth_lo = (down();1.0 / 10.0)
+val mtenth_hi = (up();1.0 / 10.0)
+val mtenth_near = (near();1.0 / 10.0)
+val mtenth_zero = (zero();1.0 / 10.0)
+
+fun word8vectorToString v = V.foldr (fn(w,s) => Word8.toString w ^ s) "" v
+
+val _ = print(word8vectorToString (P.toBytes mtenth_lo) ^ "\n")
+val _ = print(word8vectorToString (P.toBytes mtenth_hi) ^ "\n")
+val _ = print(word8vectorToString (P.toBytes mtenth_near) ^ "\n")
+val _ = print(word8vectorToString (P.toBytes mtenth_zero) ^ "\n")




More information about the MLton-commit mailing list