[MLton-commit] r6642

Vesa Karvonen vesak at mlton.org
Wed Jun 4 22:12:54 PDT 2008


Avoid conditional.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/random/unstable/detail/ran0-gen.sml

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

Modified: mltonlib/trunk/com/ssh/random/unstable/detail/ran0-gen.sml
===================================================================
--- mltonlib/trunk/com/ssh/random/unstable/detail/ran0-gen.sml	2008-06-05 04:44:24 UTC (rev 6641)
+++ mltonlib/trunk/com/ssh/random/unstable/detail/ran0-gen.sml	2008-06-05 05:12:53 UTC (rev 6642)
@@ -20,10 +20,9 @@
        fun value s = Seed.toWord (s - 0w1)
        fun next s = let
           val k = s div iq
-          val a = ia * (s - k * iq)
-          val b = ir * k
+          val s = ia * (s - k * iq) - ir * k
        in
-          if a < b then a - b + im else a - b
+          s + Seed.andb (Seed.~>> (s, 0w31), im)
        end
        fun split w = make o #2 o NumericalRecipes.psdes /> Seed.fromWord w
        val maxValue = Seed.toWord (im - 0w2))




More information about the MLton-commit mailing list