Use floating-point library methods to nudge down the result if needed. The nextAfter(r, origin) call return the next value in the direction of origin, handling cases for negative values, etc.
Changing to call nextDown for the origin is bounded at zero is just a refactoring that is clearer to read IMO. The regression test fails on an unpatched JDK. ------------- Commit messages: - Appease jcheck - JDK-8280550: SplittableRandom#nextDouble(double,double) can return result >= bound Changes: https://git.openjdk.java.net/jdk/pull/7221/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=7221&range=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8280550 Stats: 54 lines in 2 files changed: 52 ins; 0 del; 2 mod Patch: https://git.openjdk.java.net/jdk/pull/7221.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/7221/head:pull/7221 PR: https://git.openjdk.java.net/jdk/pull/7221