MERGE TO STABLE
Trac #794 reports (correctly) that the implementation of StdGen
only returns numbers in the range (0..something) rather than
(minBound, maxBound), which is what StdGen's genRange claims.
This commit fixes the problem, by implementing genRange for StdGen
(previously it just used the default method).
instance RandomGen StdGen where
next = stdNext
split = stdSplit
+ genRange _ = stdRange
instance Show StdGen where
showsPrec p (StdGen s1 s2) =
iLogBase :: Integer -> Integer -> Integer
iLogBase b i = if i < b then 1 else 1 + iLogBase b (i `div` b)
+stdRange :: (Int,Int)
+stdRange = (0, 2147483562)
+
stdNext :: StdGen -> (Int, StdGen)
+-- Returns values in the range stdRange
stdNext (StdGen s1 s2) = (z', StdGen s1'' s2'')
where z' = if z < 1 then z + 2147483562 else z
z = s1'' - s2''