[commit: packages/random] new_api: Merged patch from master. (f2088c9)
git at git.haskell.org
git at git.haskell.org
Thu Mar 19 15:43:59 UTC 2015
Repository : ssh://git@git.haskell.org/random
On branch : new_api
Link : http://git.haskell.org/packages/random.git/commitdiff/f2088c91c60b66147f40e078e89130a55cf49161
>---------------------------------------------------------------
commit f2088c91c60b66147f40e078e89130a55cf49161
Merge: 3581598 a837e1f
Author: Ryan Newton <rrnewton at gmail.com>
Date: Mon Jun 27 13:41:10 2011 -0400
Merged patch from master.
>---------------------------------------------------------------
f2088c91c60b66147f40e078e89130a55cf49161
System/Random.hs | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --cc System/Random.hs
index 4d4644b,9f5a91b..0a6c82b
--- a/System/Random.hs
+++ b/System/Random.hs
@@@ -382,26 -363,24 +389,27 @@@ instance Random Double wher
mask53 = twoto53 - 1
instance Random Float where
- randomR = randomIvalFrac
+ randomR = randomRFloating
random rng =
-- TODO: Faster to just use 'next' IF it generates enough bits of randomness.
- case random rng of
+ case rand of
(x,rng') ->
-- We use 24 bits of randomness corresponding to the 24 bit significand:
- ((fromIntegral (mask24 .&. (x::Int32)) :: Float)
+ ((fromIntegral (mask24 .&. (x::Int)) :: Float)
/ fromIntegral twoto24, rng')
-- Note, encodeFloat is another option, but I'm not seeing slightly
-- worse performance with the following [2011.06.25]:
-- (encodeFloat rand (-24), rng')
where
+ rand = case genBits rng of
+ Just n | n >= 24 -> next rng
+ _ -> random rng
mask24 = twoto24 - 1
- twoto24 = (2::Int32) ^ (24::Int32)
+ twoto24 = (2::Int) ^ (24::Int)
+ -- CFloat/CDouble are basically the same as a Float/Double:
instance Random CFloat where
- randomR = randomIvalFrac
+ randomR = randomRFloating
random rng = case random rng of
(x,rng') -> (realToFrac (x::Float), rng')
More information about the ghc-commits
mailing list