mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8280550: SplittableRandom#nextDouble(double,double) can return result >= bound
Reviewed-by: jlaskey, psandoz
This commit is contained in:
parent
a5a11f14b9
commit
0c42e43f77
2 changed files with 54 additions and 2 deletions
|
@ -645,7 +645,7 @@ public class RandomSupport {
|
|||
if (origin < bound) {
|
||||
r = r * (bound - origin) + origin;
|
||||
if (r >= bound) // may need to correct a rounding problem
|
||||
r = Double.longBitsToDouble(Double.doubleToLongBits(bound) - 1);
|
||||
r = Math.nextAfter(r, origin);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -677,7 +677,7 @@ public class RandomSupport {
|
|||
double r = rng.nextDouble();
|
||||
r = r * bound;
|
||||
if (r >= bound) // may need to correct a rounding problem
|
||||
r = Double.longBitsToDouble(Double.doubleToLongBits(bound) - 1);
|
||||
r = Math.nextDown(r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue