From 7ae59e0f0509313eb23911c9f5a701ac8849c35b Mon Sep 17 00:00:00 2001
From: Ian Lynagh
Date: Wed, 9 Mar 2011 17:43:45 +0000
Subject: [PATCH] Add a comment about why we can't use abs to get a
non-negative number NB: Negative seends will now produce different random
numbers than they used to.
---
System/Random.hs | 2 ++
1 file changed, 2 insertions(+)
diff --git a/System/Random.hs b/System/Random.hs
index 9a30b4a..a37520a 100644
--- a/System/Random.hs
+++ b/System/Random.hs
@@ -221,6 +221,8 @@ mkStdGen s = mkStdGen32 $ fromIntegral s
mkStdGen32 :: Int32 -> StdGen
mkStdGen32 sMaybeNegative = StdGen (s1+1) (s2+1)
where
+ -- We want a non-negative number, but we can't just take the abs
+ -- of sMaybeNegative as -minBound == minBound.
s = sMaybeNegative .&. maxBound
(q, s1) = s `divMod` 2147483562
s2 = q `mod` 2147483398
--
1.9.1