next method

  1. @override
int next()
override

Calculates the next seed.

Implementation

@override
int next() {
  // Linear congruence generator:
  x = ((factorParam * x) & IntMask + addParam) & IntMask;

  // Xor shift
  y = (y ^ (y << 13)) & IntMask;
  y = (y ^ (y >> 17)) & IntMask;
  y = (y ^ (y << 5)) & IntMask;

  // Multiply-with-carry: t = 698769069 * z + c; c = high(t); z = low(t);
  // tFirst cannot "overflow" (mantissa remains exact):
  var tFirst = factorParam2 * (z & FactorMask);
  z = ((tFirst & IntMask) + c) & FactorMask;
  c = ((tFirst + c) >> 26) & FactorMask;

  final rc = (x + y + z) & IntMask;
  if (logger.logLevel >= LEVEL_DEBUG) {
    logger.log('$id: next: $rc');
  }
  return rc;
}