Class LCG48
C# reimplementation of Java's PRNG, a linear congruential generator (LCG).
public class LCG48 : Random
- Inheritance
-
LCG48
- Inherited Members
Remarks
Useful links:
Constructors
LCG48()
public LCG48()
LCG48(int)
public LCG48(int seed)
Parameters
seedint
LCG48(long)
public LCG48(long seed)
Parameters
seedlong
Methods
Next()
Returns a non-negative random integer.
public override int Next()
Returns
Next(int, int)
Returns a random integer that is within a specified range.
public override int Next(int minValue, int maxValue)
Parameters
minValueintThe inclusive lower bound of the random number returned.
maxValueintThe exclusive upper bound of the random number returned.
maxValuemust be greater than or equal tominValue.
Returns
- int
A 32-bit signed integer greater than or equal to
minValueand less thanmaxValue; that is, the range of return values includesminValuebut notmaxValue. IfminValueequalsmaxValue,minValueis returned.
Exceptions
- ArgumentOutOfRangeException
minValueis greater thanmaxValue.
NextBytes(byte[])
Fills the elements of a specified array of bytes with random numbers.
public override void NextBytes(byte[] buffer)
Parameters
bufferbyte[]An array of bytes to contain random numbers.
Exceptions
- ArgumentNullException
bufferis null.
Sample()
Returns a random floating-point number between 0.0 and 1.0.
protected override double Sample()
Returns
- double
A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.