On Wed, 6 Apr 2022 17:47:53 GMT, Chris Hennick <d...@openjdk.java.net> wrote:
> Repeatedly adding DoubleZigguratTables.exponentialX0 to extra causes a > rounding error to accumulate at the tail of the distribution (probably > starting around 2*exponentialX0 == 0x1.e46eff20739afp3 ~ 15.1); this fixes > that by tracking the multiple of exponentialX0 as a long. (This changes the > maximum possible output to `1.0p63 * DoubleZigguratTables.exponentialX0 == > 0x1.e46eff20739afp65`; previously it would have been `0x1.0p56` because once > `extra` reaches that amount, `x + extra == extra` due to the rounding error. > This lowers the probability of reaching the maximum with an ideal PRNG from > about `1.3877787807814488E-17` to about `1.4323726067488646E-20` (calculated > using the identity `ln(x) == Math.log10(x)/Math.log10(Math.exp(1))`). src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java line 1411: > 1409: long U2 = (rng.nextLong() >>> 1); > 1410: // Compute the actual x-coordinate of the randomly > chosen point. > 1411: x = Math.fma(X[j-1] - X[j], (double)U1, X[j] * > 0x1.0p63)); Code is not compilable ------------- PR: https://git.openjdk.java.net/jdk/pull/8131