RFR: 8202449: overflow handling in Random.doubles [v3]
Joe Darcy
darcy at openjdk.java.net
Wed Jun 8 01:22:32 UTC 2022
On Tue, 24 May 2022 12:58:45 GMT, Raffaello Giulietti <duke at openjdk.java.net> 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
More information about the core-libs-dev
mailing list