RFR: 8302987: Add uniform and spatially equidistributed bounded double streams to RandomGenerator [v10]
Raffaello Giulietti
rgiulietti at openjdk.org
Tue Jul 18 08:20:29 UTC 2023
On Tue, 18 Jul 2023 02:54:55 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> Raffaello Giulietti has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Correction in comment.
>
> src/java.base/share/classes/java/util/random/RandomGenerator.java line 398:
>
>> 396: * afforded by nextLong().
>> 397: */
>> 398: delta = nextUp(left) - left;
>
> The delta computations are equivalent to some expression phrased in terms of an ulp (Math.ulp) of a the endpoint or a value adjacent to the endpoint. If the ulp method is not used for the computation, I suggest adding a comment noting the equivalence.
Here `left` is negative or `0.0`. What is needed is the distance to the next adjacent `double` in the direction of positive infinity. This is almost always the same as `Math.ulp(left)`, but not always.
For example, when `left` is `-1.0`, `delta` as computed here is half of `Math.ulp(left)`.
Analogously for the case covered by the `else` arm.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/12719#discussion_r1266404939
More information about the core-libs-dev
mailing list