Re: RFR: 8202449: overflow handling in Random.doubles [v3]
On Tue, 24 May 2022 12:58:45 GMT, Raffaello Giulietti wrote: >> Extend the range of Random.doubles(double, double) and similar methods. > > Raffaello Giulietti has updated the pull request incrementally with one > additional commit since the last revision: > > 8202449: overflow handling in Random.doubles Marked as reviewed by darcy (Reviewer). src/java.base/share/classes/jdk/internal/util/random/RandomSupport.java line 733: > 731: /* avoids overflow at the cost of 3 more multiplications > */ > 732: float halfOrigin = 0.5f * origin; > 733: r = (r * (0.5f * bound - halfOrigin) + halfOrigin) * > 2.0f; This could be done in double arithmetic, but I think it is better to keep it in float arithmetic for similarity with the code in the double version of the method. - PR: https://git.openjdk.java.net/jdk/pull/8791
Re: RFR: 8202449: overflow handling in Random.doubles [v3]
On Tue, 24 May 2022 12:58:45 GMT, Raffaello Giulietti wrote: >> Extend the range of Random.doubles(double, double) and similar methods. > > Raffaello Giulietti has updated the pull request incrementally with one > additional commit since the last revision: > > 8202449: overflow handling in Random.doubles Hi, the major code changes are in `RandomSupport` in methods checkRange(float,float) checkRange(double,double) where the checks are more tolerant, and in boundedNextDouble(RandomGenerator,double,double) boundedNextFloat(RandomGenerator,float,float) that extend the accepted range. In case the range size overflows, the methods half the range, generate a value inside the reduced range and finally double the outcome. - PR: https://git.openjdk.java.net/jdk/pull/8791
Re: RFR: 8202449: overflow handling in Random.doubles [v3]
On Tue, 24 May 2022 12:58:45 GMT, Raffaello Giulietti wrote: >> Extend the range of Random.doubles(double, double) and similar methods. > > Raffaello Giulietti has updated the pull request incrementally with one > additional commit since the last revision: > > 8202449: overflow handling in Random.doubles `Random.doubles(double, double)` and similar methods depend on `RandomGenerator.nextDouble(double, double)`. Currently, this method is specified to throw when the range [origin, bound) given by the arguments is so large that its size (bound - origin) overflows. Since the proposed implementation doesn't suffer from this limitation, the specification needs to be modified, thus the need for a CSR. - PR: https://git.openjdk.java.net/jdk/pull/8791
Re: RFR: 8202449: overflow handling in Random.doubles [v3]
> Extend the range of Random.doubles(double, double) and similar methods. Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision: 8202449: overflow handling in Random.doubles - Changes: - all: https://git.openjdk.java.net/jdk/pull/8791/files - new: https://git.openjdk.java.net/jdk/pull/8791/files/62322ac1..954d1ea2 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=8791=02 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8791=01-02 Stats: 21 lines in 2 files changed: 0 ins; 8 del; 13 mod Patch: https://git.openjdk.java.net/jdk/pull/8791.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8791/head:pull/8791 PR: https://git.openjdk.java.net/jdk/pull/8791
Re: RFR: 8202449: overflow handling in Random.doubles [v2]
> Extend the range of Random.doubles(double, double) and similar methods. Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision: 8202449: overflow handling in Random.doubles - Changes: - all: https://git.openjdk.java.net/jdk/pull/8791/files - new: https://git.openjdk.java.net/jdk/pull/8791/files/936a5bc1..62322ac1 Webrevs: - full: https://webrevs.openjdk.java.net/?repo=jdk=8791=01 - incr: https://webrevs.openjdk.java.net/?repo=jdk=8791=00-01 Stats: 5 lines in 1 file changed: 0 ins; 3 del; 2 mod Patch: https://git.openjdk.java.net/jdk/pull/8791.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8791/head:pull/8791 PR: https://git.openjdk.java.net/jdk/pull/8791
RFR: 8202449: overflow handling in Random.doubles
Extend the range of Random.doubles(double, double) and similar methods. - Commit messages: - 8202449: overflow handling in Random.doubles Changes: https://git.openjdk.java.net/jdk/pull/8791/files Webrev: https://webrevs.openjdk.java.net/?repo=jdk=8791=00 Issue: https://bugs.openjdk.java.net/browse/JDK-8202449 Stats: 108 lines in 4 files changed: 47 ins; 25 del; 36 mod Patch: https://git.openjdk.java.net/jdk/pull/8791.diff Fetch: git fetch https://git.openjdk.java.net/jdk pull/8791/head:pull/8791 PR: https://git.openjdk.java.net/jdk/pull/8791