Merge pull request #425 from shenqioa/master

RandomUtils : comment error
This commit is contained in:
Bruno P. Kinoshita 2019-08-25 10:51:39 +12:00 committed by GitHub
commit 094ee7ecbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View File

@ -166,23 +166,23 @@ public class RandomUtils {
*
* @param startInclusive
* the smallest value that can be returned, must be non-negative
* @param endInclusive
* the upper bound (included)
* @param endExclusive
* the upper bound (not included)
* @throws IllegalArgumentException
* if {@code startInclusive > endInclusive} or if
* if {@code startInclusive > endExclusive} or if
* {@code startInclusive} is negative
* @return the random double
*/
public static double nextDouble(final double startInclusive, final double endInclusive) {
Validate.isTrue(endInclusive >= startInclusive,
public static double nextDouble(final double startInclusive, final double endExclusive) {
Validate.isTrue(endExclusive >= startInclusive,
"Start value must be smaller or equal to end value.");
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
if (startInclusive == endInclusive) {
if (startInclusive == endExclusive) {
return startInclusive;
}
return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextDouble());
return startInclusive + ((endExclusive - startInclusive) * RANDOM.nextDouble());
}
/**
@ -203,30 +203,30 @@ public class RandomUtils {
*
* @param startInclusive
* the smallest value that can be returned, must be non-negative
* @param endInclusive
* the upper bound (included)
* @param endExclusive
* the upper bound (not included)
* @throws IllegalArgumentException
* if {@code startInclusive > endInclusive} or if
* if {@code startInclusive > endExclusive} or if
* {@code startInclusive} is negative
* @return the random float
*/
public static float nextFloat(final float startInclusive, final float endInclusive) {
Validate.isTrue(endInclusive >= startInclusive,
public static float nextFloat(final float startInclusive, final float endExclusive) {
Validate.isTrue(endExclusive >= startInclusive,
"Start value must be smaller or equal to end value.");
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
if (startInclusive == endInclusive) {
if (startInclusive == endExclusive) {
return startInclusive;
}
return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextFloat());
return startInclusive + ((endExclusive - startInclusive) * RANDOM.nextFloat());
}
/**
* <p> Returns a random float within 0 - Float.MAX_VALUE </p>
*
* @return the random float
* @see #nextFloat()
* @see #nextFloat(float, float)
* @since 3.5
*/
public static float nextFloat() {

View File

@ -137,7 +137,7 @@ public class RandomUtilsTest {
}
/**
* Tests next double range, random result.
* Tests next int range, random result.
*/
@Test
public void testNextIntRandomResult() {