8202449: overflow handling in Random.doubles

Reviewed-by: darcy
This commit is contained in:
Raffaello Giulietti 2022-06-08 16:28:18 +00:00 committed by Joe Darcy
parent c15e10fb6c
commit c8cff1bd6f
5 changed files with 82 additions and 71 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,6 @@
*/
package java.util;
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.random.RandomGenerator;
import java.util.random.RandomGenerator.SplittableGenerator;
@ -551,9 +550,7 @@ public final class SplittableRandom implements RandomGenerator, SplittableGenera
* @param randomNumberBound the bound (exclusive) of each random value
* @return a stream of pseudorandom {@code double} values,
* each with the given origin (inclusive) and bound (exclusive)
* @throws IllegalArgumentException if {@code streamSize} is
* less than zero, or {@code randomNumberOrigin}
* is greater than or equal to {@code randomNumberBound}
* @throws IllegalArgumentException {@inheritDoc}
*/
@Override
public DoubleStream doubles(long streamSize, double randomNumberOrigin, double randomNumberBound) {
@ -572,8 +569,7 @@ public final class SplittableRandom implements RandomGenerator, SplittableGenera
* @param randomNumberBound the bound (exclusive) of each random value
* @return a stream of pseudorandom {@code double} values,
* each with the given origin (inclusive) and bound (exclusive)
* @throws IllegalArgumentException if {@code randomNumberOrigin}
* is greater than or equal to {@code randomNumberBound}
* @throws IllegalArgumentException {@inheritDoc}
*/
@Override
public DoubleStream doubles(double randomNumberOrigin, double randomNumberBound) {