[MLton-commit] r6105

Vesa Karvonen vesak at mlton.org
Mon Oct 29 04:20:16 PST 2007


Workaround for lack of Real.fromLargeInt in MLKit.

Interestingly, Math.pow in SML/NJ (built from SVN rev 2815) does not
produce the correct answer for Math.pow (2.0, 53.0).  The following
expression evaluates to false:

  Real.== (Math.pow (2.0, 53.0) - 1.0,
           Real.fromLargeInt (IntInf.<< (1, Word.fromInt Real.precision) - 1))

OTOH, the expression evaluates to true in Poly/ML 5.1 (built from CVS).

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

U   mltonlib/trunk/com/ssh/random/unstable/detail/mk-random-gen.fun

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

Modified: mltonlib/trunk/com/ssh/random/unstable/detail/mk-random-gen.fun
===================================================================
--- mltonlib/trunk/com/ssh/random/unstable/detail/mk-random-gen.fun	2007-10-29 11:31:27 UTC (rev 6104)
+++ mltonlib/trunk/com/ssh/random/unstable/detail/mk-random-gen.fun	2007-10-29 12:20:15 UTC (rev 6105)
@@ -109,6 +109,8 @@
    local
       val () = if R.radix <> 2 then fail "Real.radix <> 2" else ()
       val d = R.fromLargeInt (IntInf.<< (1, W.fromInt R.precision) - 1)
+          handle _ => Math.pow (2.0, real R.precision) - 1.0
+          (* XXX The handler is/was a MLKit workaround; see Extended Basis *)
    in
       fun realInRange (l, h) =
           (assert (fn () => l <= h)




More information about the MLton-commit mailing list