A pseudorandom number generator.

The algorithm used by this class to generate pseudorandom numbers may be platform specific and is subject to change in future versions of this module.

Currently, A Linear Congruential Generator (LCG) pseudorandom number generator is used, as defined by the recurrence relation:

Xₙ₊₁ ≡ (a Xₙ + c) (mod m)

The following parameters are used for the JVM:

a = 25214903917
c = 11
m = 2^48
output bits = 16..47

And for JavaScript:

a = 214013
c = 2531011
m = 2^32
output bits = 16..30

See http://en.wikipedia.org/wiki/Linear_congruential_generator

no subtypes hierarchy

Initializer
DefaultRandom(Integer seed = ...)
Parameters:
  • seed = nextUniqueSeed

    The seed. The value is processed by reseed() prior to use.

Inherited Attributes
Attributes inherited from: Object
Methods
nextBitsSource Codeshared actual Integer nextBits(Integer bits)

Generates an Integer holding bits pseudorandom bits. The returned value will be:

  • equal to 0 for bits <= 0
  • in the range 0..(2^n - 1) for bits in 1..63
  • in the range -2^63..(2^63 - 1) for bits == 64

Note that bits may not be greater than randomLimits.maxBits.

reseedSource Codeshared void reseed(Integer newSeed)

Reseed this random number generator. For the Java runtime, the seed value is processed using newSeed.xor(a).and(m - 1) prior to use, and for the JavaScript runtime, newSeed.magnitude % m.

Inherited Methods
Methods inherited from: Object
Methods inherited from: Random