RFR: 8202449: overflow handling in Random.doubles [v3]

Raffaello Giulietti duke at openjdk.java.net
Tue Jun 7 08:56:05 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

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


More information about the core-libs-dev mailing list