8 [__DynamicallyInvokable]
11 private const int MBIG =
int.MaxValue;
13 private const int MSEED = 161803398;
15 private const int MZ = 0;
21 private int[] SeedArray =
new int[56];
24 [__DynamicallyInvokable]
32 [__DynamicallyInvokable]
35 int num = (Seed ==
int.MinValue) ?
int.MaxValue :
Math.
Abs(Seed);
36 int num2 = 161803398 - num;
39 for (
int i = 1; i < 55; i++)
41 int num4 = 21 * i % 55;
42 SeedArray[num4] = num3;
48 num2 = SeedArray[num4];
50 for (
int j = 1; j < 5; j++)
52 for (
int k = 1; k < 56; k++)
54 SeedArray[k] -= SeedArray[1 + (k + 30) % 55];
57 SeedArray[k] +=
int.MaxValue;
68 [__DynamicallyInvokable]
71 return (
double)InternalSample() * 4.6566128752457969E-10;
74 private int InternalSample()
86 int num3 = SeedArray[num] - SeedArray[num2];
87 if (num3 ==
int.MaxValue)
95 SeedArray[num] = num3;
103 [__DynamicallyInvokable]
106 return InternalSample();
109 private double GetSampleForLargeRange()
111 int num = InternalSample();
112 if ((InternalSample() % 2 == 0) ?
true :
false)
117 num2 += 2147483646.0;
118 return num2 / 4294967293.0;
127 [__DynamicallyInvokable]
128 public virtual int Next(
int minValue,
int maxValue)
130 if (minValue > maxValue)
134 long num = (long)maxValue - (
long)minValue;
135 if (num <=
int.MaxValue)
137 return (
int)(
Sample() * (double)num) + minValue;
139 return (
int)((long)(GetSampleForLargeRange() * (double)num) + minValue);
147 [__DynamicallyInvokable]
148 public virtual int Next(
int maxValue)
154 return (
int)(
Sample() * (double)maxValue);
159 [__DynamicallyInvokable]
169 [__DynamicallyInvokable]
176 for (
int i = 0; i < buffer.Length; i++)
178 buffer[i] = (byte)(InternalSample() % 256);
Represents a pseudo-random number generator, which is a device that produces a sequence of numbers th...
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
The exception that is thrown when the value of an argument is outside the allowable range of values a...
virtual double Sample()
Returns a random floating-point number between 0.0 and 1.0.
Provides information about, and means to manipulate, the current environment and platform....
virtual int Next(int minValue, int maxValue)
Returns a random integer that is within a specified range.
virtual int Next(int maxValue)
Returns a non-negative random integer that is less than the specified maximum.
virtual void NextBytes(byte[] buffer)
Fills the elements of a specified array of bytes with random numbers.
virtual int Next()
Returns a non-negative random integer.
virtual double NextDouble()
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1....
static sbyte Abs(sbyte value)
Returns the absolute value of an 8-bit signed integer.
Random(int Seed)
Initializes a new instance of the T:System.Random class, using the specified seed value.
Random()
Initializes a new instance of the T:System.Random class, using a time-dependent default seed value.
Specifies that the class can be serialized.
Provides constants and static methods for trigonometric, logarithmic, and other common mathematical f...