Class Random::MT19937
In: lib/backports/1.9.2/random/MT19937.rb
lib/backports/1.9.2/random/bits_and_bytes.rb
Parent: Object

Supplement the MT19937 class with methods to do conversions the same way as MRI. No argument checking is done here either.

Methods

Constants

STATE_SIZE = 624
LAST_STATE = STATE_SIZE - 1
PAD_32_BITS = 0xffffffff
LAST_31_BITS = 0x7fffffff
OFFSET = 397
FLOAT_FACTOR = 1.0/9007199254740992.0
MASK_BY = [1,2,4,8,16]

Public Class methods

Convert an Integer seed of arbitrary size to either a single 32 bit integer, or an Array of 32 bit integers

Public Instance methods

Generates a completely new state out of the previous one.

Returns a random Integer from the range 0 … (1 << 32)

generates a random number on [0,1) with 53-bit resolution

Returns an integer within 0...upto

Seed must be either an Integer (only the first 32 bits will be used) or an Array of Integers (of which only the first 32 bits will be used)

No conversion or type checking is done at this level

[Validate]