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