### Subversion checkout URL

You can clone with HTTPS or Subversion.

 `@@ -114,7 +114,11 @@ getTime = do` 114 114 ` -- | The class 'RandomGen' provides a common interface to random number` 115 115 ` -- generators.` 116 116 ` --` 117 `+#ifdef ENABLE_SPLITTABLEGEN` 117 118 ` -- Minimal complete definition: 'next'.` 119 `+#else` 120 `+-- Minimal complete definition: 'next' and 'split'.` 121 `+#endif` 118 122 ` ` 119 123 ` class RandomGen g where` 120 124 ` ` `@@ -147,7 +151,7 @@ class RandomGen g where` 147 151 ` ` 148 152 ` #ifdef ENABLE_SPLITTABLEGEN` 149 153 ` -- | The class 'SplittableGen' proivides a way to specify a random number` 150 `--- generator that can be split into two new generators.` 154 `+-- generator that can be split into two new generators.` 151 155 ` class SplittableGen g where` 152 156 ` #endif` 153 157 ` -- |The 'split' operation allows one to obtain two distinct random number` `@@ -423,14 +427,17 @@ randomIvalInteger (l,h) rng` 423 427 ` | otherwise = case (f n 1 rng) of (v, rng') -> (fromInteger (l + v `mod` k), rng')` 424 428 ` where` 425 429 ` k = h - l + 1` 430 `+ -- ERROR: b here (2^31-87) represents a baked-in assumption about genRange:` 426 431 ` b = 2147483561` 427 432 ` n = iLogBase b k` 428 433 ` ` 434 `+ -- Here we loop until we've generated enough randomness to cover the range:` 429 435 ` f 0 acc g = (acc, g)` 430 436 ` f n' acc g =` 431 437 ` let` 432 438 ` (x,g') = next g` 433 439 ` in` 440 `+ -- We shift over the random bits generated thusfar (* b) and add in the new ones.` 434 441 ` f (n' - 1) (fromIntegral x + acc * b) g'` 435 442 ` ` 436 443 ` -- The continuous functions on the other hand take an [inclusive,exclusive) range.` `@@ -454,6 +461,10 @@ randomIvalDouble (l,h) fromDouble rng` 454 461 ` int32Count :: Integer` 455 462 ` int32Count = toInteger (maxBound::Int32) - toInteger (minBound::Int32) + 1` 456 463 ` ` 464 `+-- Perform an expensive logarithm on arbitrary-size integers by repeated division.` 465 `+-- ` 466 `+-- (NOTE: This actually returns ceiling(log(i) base b) except with an` 467 `+-- incorrect result at iLogBase b b = 2.)` 457 468 ` iLogBase :: Integer -> Integer -> Integer` 458 469 ` iLogBase b i = if i < b then 1 else 1 + iLogBase b (i `div` b)` 459 470 ` `