Skip to content

Commit 5342def

Browse files
committed
Use a literal for the LCG modulus
Also add a comment explaining the choice of the value.
1 parent a21d767 commit 5342def

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Test/QuickCheck/LCG.purs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ lcgM = 48271
2626
lcgC :: Int
2727
lcgC = 0
2828

29-
-- | The *modulus*: a magic constant for the linear congruential generator
29+
-- | The *modulus*: a magic constant for the linear congruential generator.
30+
-- | It is equal to 2^31 - 1, a Mersenne prime. It is useful for this value to
31+
-- | be prime, because then the requirement of the initial seed being coprime
32+
-- | to the modulus is satisfied when the seed is between 1 and lcgN - 1.
3033
lcgN :: Int
31-
lcgN = 1 `shl` 31 - 1
34+
lcgN = 2147483647
3235

3336
-- | Step the linear congruential generator
3437
lcgNext :: Int -> Int

0 commit comments

Comments
 (0)