nextRaw32 method

  1. @override
int nextRaw32()
override

Generates a non-negative random integer uniformly distributed in the range from 0 to 0xFFFFFFFF, both inclusive.

For individual algorithms, these boundaries may actually differ. For example, algorithms in the Xorshift family never return zero.

It is the raw output of the generator.

Implementation

@override
int nextRaw32() {
  // algorithm from p.5 of "Xorshift RNGs"
  // by George Marsaglia, 2003
  // https://www.jstatsoft.org/article/view/v008i14
  //
  // rewritten for Dart from snippet
  // found at https://en.wikipedia.org/wiki/Xorshift

  var t = _d;
  final s = _a;
  _d = _c;
  _c = _b;
  _b = s;

  t ^= t << 11;
  t &= 0xFFFFFFFF;

  // rewritten `t ^= t.unsignedRightShift(8); //t ^= t >> 8;`
  t ^= (t >> 8) & ~(-1 << (64 - 8));

  _a = t ^ s ^ (s >> 19);
  _a &= 0xFFFFFFFF;

  return _a;
}