Evolution/Evolution/Utils/XorShiftRandomSource.cs
/// <summary>
/// Generates a random int over the range 0 to upperBound-1, and not including upperBound.
/// </summary>
Generates a random int over the range 0 to upperBound-1, and not including upperBound.
Generates a random int over the range 0 to upperBound - 1 and not including upperBound .
public int Next(int upperBound)
        {
            if (upperBound < 0)
            {
                throw new ArgumentOutOfRangeException("upperBound", upperBound, "upperBound must be >=0");
            }
            uint t = _x ^ (_x << 11);
            _x = _y; _y = _z; _z = _w;
            return (int)((REAL_UNIT_UINT * (_w = (_w ^ (_w >> 19)) ^ (t ^ (t >> 8)))) * upperBound);
        }
public int Next ( int upperBound ) { if ( upperBound < 0 ) { throw new ArgumentOutOfRangeException ( " " , upperBound , " " ) ; } uint t = _x ^ ( _x << 11 ) ; _x = _y ; _y = _z ; _z = _w ; return ( int ) ( ( REAL_UNIT_UINT * ( _w = ( _w ^ ( _w >> 19 ) ) ^ ( t ^ ( t >> 8 ) ) ) ) * upperBound ) ; }
Generates a random int over the range 0 to upperBound-1, and not including upperBound.
Generates a random int over the range 0 to upperBound - 1 and not including upperBound .
// ENHANCEMENT: Can we do this without converting to a double and back again? // The explicit int cast before the first multiplication gives better performance. // See comments in NextDouble.
upperBound
int