Merge pull request #425 from shenqioa/master
RandomUtils : comment error
This commit is contained in:
commit
094ee7ecbd
|
@ -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() {
|
||||
|
|
|
@ -137,7 +137,7 @@ public class RandomUtilsTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests next double range, random result.
|
||||
* Tests next int range, random result.
|
||||
*/
|
||||
@Test
|
||||
public void testNextIntRandomResult() {
|
||||
|
|
Loading…
Reference in New Issue