nextDouble method

  1. @override
double nextDouble()
override

Generates a random floating point value uniformly distributed in the range from 0.0, inclusive, to 1.0, exclusive.

The results of this method exactly repeat the numbers usually generated by algorithms in C99 or C++. For example, this allows you to accurately reproduce the values of the generator used in the Chrome browser.

In C99, the type conversion is described by S. Vigna as follows:

static inline double to_double(uint64_t x) {
  const union { uint64_t i; double d; } u = {
    .i = UINT64_C(0x3FF) << 52 | x >> 12
  };
  return u.d - 1.0;
}

Implementation

@override
double nextDouble() {
  return nextRaw32() * 2.3283064365386963e-10 +
      (nextRaw32() >> 12) * 2.220446049250313e-16;
}