Class LcgRndInt32
java.lang.Object
io.github.olyutorskii.aletojio.rng.lcg.AbstractLcg
io.github.olyutorskii.aletojio.rng.lcg.LcgRndInt32
- All Implemented Interfaces:
RndInt32
Implementation of 32bit output Linear congruential generator(LCG).
LCG is a commonly used random number generator in the past.
Recurrence relation sequences : X(n+1) = (X(n) * Mul + Inc) mod Mod
- Mul : Multiplier
- Inc : Increment
- Mod : Modulus
- See Also:
-
Field Summary
Fields inherited from class io.github.olyutorskii.aletojio.rng.lcg.AbstractLcg
MASK_B31, MASK_B32
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Return next random number as 32bit int with random sign-bit.protected int
Calculate result number from seed.Methods inherited from class io.github.olyutorskii.aletojio.rng.lcg.AbstractLcg
getSeed, nextIntImpl, nextSeed, setSeed
-
Constructor Details
-
LcgRndInt32
Constructor.- Multiplier must be 1 or greatrer.
- Increment must be 0 or greatrer.
- Modulus must be 2 or greater.
- Parameters:
mulArg
- multiplierincArg
- incrementmodArg
- modulus- Throws:
IllegalArgumentException
- illegal argument
-
-
Method Details
-
seedToResult
protected int seedToResult()Calculate result number from seed.result(32bit) reflects seed[16:47]
- Specified by:
seedToResult
in classAbstractLcg
- Returns:
- result number
-
nextInt32
public int nextInt32()Return next random number as 32bit int with random sign-bit.
-