nextInt64 method
Int64
nextInt64()
Returns the next random number.
Note that this returns a signed integer that is potentially negative if w is 64. To match values from Mersenne Twister implementations that operate over unsigned integers, use call() instead.
Implementation
Int64 nextInt64() {
// Generate [n] words at one time.
if (_stateIndex >= n) {
if (_stateIndex == n + 1) {
init(Int64(defaultSeed));
}
int i;
for (i = 0; i < n - m; i += 1) {
var x = (_state[i] & _upperMask) | (_state[i + 1] & _lowerMask);
_state[i] = _state[i + m] ^ (x >>> 1) ^ ((x & Int64.ONE) * a);
}
for (; i < n - 1; i += 1) {
var x = (_state[i] & _upperMask) | (_state[i + 1] & _lowerMask);
_state[i] = _state[i + m - n] ^ (x >>> 1) ^ ((x & Int64.ONE) * a);
}
var x = (_state[n - 1] & _upperMask) | (_state[0] & _lowerMask);
_state[n - 1] = _state[m - 1] ^ (x >>> 1) ^ ((x & Int64.ONE) * a);
_stateIndex = 0;
}
var x = _state[_stateIndex];
_stateIndex += 1;
// Tempering.
x ^= (x >>> u) & d;
x ^= (x << s) & b;
x ^= (x << t) & c;
x ^= x >>> l;
return x;
}