Xorshift128 constructor

Xorshift128([
  1. int? a,
  2. int? b,
  3. int? c,
  4. int? d,
])

Implementation

Xorshift128([int? a, int? b, int? c, int? d]) {
  if (a != null || b != null || c != null || d != null) {
    RangeError.checkValueInInterval(a!, 0, UINT32_MAX);
    RangeError.checkValueInInterval(b!, 0, UINT32_MAX);
    RangeError.checkValueInInterval(c!, 0, UINT32_MAX);
    RangeError.checkValueInInterval(d!, 0, UINT32_MAX);

    if (a == 0 && b == 0 && c == 0 && d == 0) {
      throw ArgumentError('The seed should not consist of only zeros..');
    }

    _a = a;
    _b = b;
    _c = c;
    _d = d;
  } else {
    final now = DateTime.now().microsecondsSinceEpoch;
    // just creating a mess

    _a = mess2to64A(now, this.hashCode) & 0xFFFFFFFF;
    _b = mess2to64B(now, this.hashCode) & 0xFFFFFFFF;
    _c = mess2to64C(now, this.hashCode) & 0xFFFFFFFF;
    _d = mess2to64D(now, this.hashCode) & 0xFFFFFFFF;
  }
}