Evolution/Evolution/Utils/XorShiftRandomSource.cs
/// <summary>
/// Generates a signle random byte with range [0,255].
/// This method's performance is improved by generating 4 bytes in one operation and storing them
/// ready for future calls.
/// </summary>
Generates a signle random byte with range [0,255].
This method's performance is improved by generating 4 bytes in one operation and storing them
ready for future calls.
Generates a signle random byte with range [ 0 255 ] . This method ' s performance is improved by generating 4 bytes in one operation and storing them ready for future calls .
public byte NextByte()
        {
            if (0 == _byteBufferState)
            {
                uint t = _x ^ (_x << 11);
                _x = _y; _y = _z; _z = _w;
                _byteBuffer = _w = (_w ^ (_w >> 19)) ^ (t ^ (t >> 8));
                _byteBufferState = 0x4;
                return (byte)_byteBuffer;  
            }
            _byteBufferState >>= 1;
            return (byte)(_byteBuffer >>= 8);
        }
public byte NextByte ( ) { if ( 0 == _byteBufferState ) { uint t = _x ^ ( _x << 11 ) ; _x = _y ; _y = _z ; _z = _w ; _byteBuffer = _w = ( _w ^ ( _w >> 19 ) ) ^ ( t ^ ( t >> 8 ) ) ; _byteBufferState = 0x4 ; return ( byte ) _byteBuffer ; } _byteBufferState >>= 1 ; return ( byte ) ( _byteBuffer >>= 8 ) ; }
Generates a signle random byte with range [0,255].
Generates a signle random byte with range [ 0 255 ] .
// Generate 4 more bytes. // Note. Masking with 0xFF is unnecessary.