Back to class index
LCG[Class Summary]
multiplier
increment
modulus
lastNumber
ctor (+1 overload)
Seed(...)
Int()
MaxInt()[const]
IntFast()
Int(a,b)
Float()
Float01Incl()
FloatNeg1_1()
Float(a,b)
FloatIncl(a,b)

LCG::Seed

Syntax

void LCG::Seed(u32 seed, u32 multiplier=69621, u32 increment=0, u32 modulus=0x7FFFFFFF); [15 lines of code]

Reinitializes the generator to the new settings.

If you want to give different parameters for the generator, you should remember that:

  • modulus should be prime

  • modulus, increment and the multiplier should all be relative primes (increment can be 0)

  • modulus should be greater than multiplier and increment

Most often you can leave increment = 0.

A list of widely used values:

  • Park and Miller (Minimal standard): mul = 16807 (7^5) mod = 2^31 - 1 (2147483647 == 0x7FFFFFFF)

  • Park and Miller #2: mul = 48271 mod = 2^31 - 1

  • Park and Miller #3: mul = 69621 mod = 2^31 - 1

  • SIMSCRIPT: mul = 630360016 mod = 2^31 - 1

  • URN12: mul = 452807053 mod = 2^31

Infamous examples (Don't use!):

  • Classical ANSI C mul = 1103515245 inc = 12345 mod = 2^31

  • RANDU mul = 65539 mod = 2^31