Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetInt32() [1/2]

static int System.Security.Cryptography.RandomNumberGenerator.GetInt32 ( int fromInclusive,
int toExclusive )
inlinestaticinherited

Definition at line 90 of file RandomNumberGenerator.cs.

91 {
92 if (fromInclusive >= toExclusive)
93 {
95 }
96 uint num = (uint)(toExclusive - fromInclusive - 1);
97 if (num == 0)
98 {
99 return fromInclusive;
100 }
101 uint num2 = num;
102 num2 |= num2 >> 1;
103 num2 |= num2 >> 2;
104 num2 |= num2 >> 4;
105 num2 |= num2 >> 8;
106 num2 |= num2 >> 16;
107 Span<uint> span = stackalloc uint[1];
108 uint num3;
109 do
110 {
111 RandomNumberGeneratorImplementation.FillSpan(MemoryMarshal.AsBytes(span));
112 num3 = num2 & span[0];
113 }
114 while (num3 > num);
115 return (int)num3 + fromInclusive;
116 }
static string Argument_InvalidRandomRange
Definition SR.cs:20
Definition SR.cs:7

References System.SR.Argument_InvalidRandomRange, and System.Security.Cryptography.RandomNumberGeneratorImplementation.FillSpan().

Referenced by System.Security.Cryptography.RandomNumberGenerator.GetInt32().