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
|
* @param startInclusive
|
||||||
* the smallest value that can be returned, must be non-negative
|
* the smallest value that can be returned, must be non-negative
|
||||||
* @param endInclusive
|
* @param endExclusive
|
||||||
* the upper bound (included)
|
* the upper bound (not included)
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if {@code startInclusive > endInclusive} or if
|
* if {@code startInclusive > endExclusive} or if
|
||||||
* {@code startInclusive} is negative
|
* {@code startInclusive} is negative
|
||||||
* @return the random double
|
* @return the random double
|
||||||
*/
|
*/
|
||||||
public static double nextDouble(final double startInclusive, final double endInclusive) {
|
public static double nextDouble(final double startInclusive, final double endExclusive) {
|
||||||
Validate.isTrue(endInclusive >= startInclusive,
|
Validate.isTrue(endExclusive >= startInclusive,
|
||||||
"Start value must be smaller or equal to end value.");
|
"Start value must be smaller or equal to end value.");
|
||||||
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
|
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
|
||||||
|
|
||||||
if (startInclusive == endInclusive) {
|
if (startInclusive == endExclusive) {
|
||||||
return startInclusive;
|
return startInclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextDouble());
|
return startInclusive + ((endExclusive - startInclusive) * RANDOM.nextDouble());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,30 +203,30 @@ public class RandomUtils {
|
||||||
*
|
*
|
||||||
* @param startInclusive
|
* @param startInclusive
|
||||||
* the smallest value that can be returned, must be non-negative
|
* the smallest value that can be returned, must be non-negative
|
||||||
* @param endInclusive
|
* @param endExclusive
|
||||||
* the upper bound (included)
|
* the upper bound (not included)
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if {@code startInclusive > endInclusive} or if
|
* if {@code startInclusive > endExclusive} or if
|
||||||
* {@code startInclusive} is negative
|
* {@code startInclusive} is negative
|
||||||
* @return the random float
|
* @return the random float
|
||||||
*/
|
*/
|
||||||
public static float nextFloat(final float startInclusive, final float endInclusive) {
|
public static float nextFloat(final float startInclusive, final float endExclusive) {
|
||||||
Validate.isTrue(endInclusive >= startInclusive,
|
Validate.isTrue(endExclusive >= startInclusive,
|
||||||
"Start value must be smaller or equal to end value.");
|
"Start value must be smaller or equal to end value.");
|
||||||
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
|
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
|
||||||
|
|
||||||
if (startInclusive == endInclusive) {
|
if (startInclusive == endExclusive) {
|
||||||
return startInclusive;
|
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>
|
* <p> Returns a random float within 0 - Float.MAX_VALUE </p>
|
||||||
*
|
*
|
||||||
* @return the random float
|
* @return the random float
|
||||||
* @see #nextFloat()
|
* @see #nextFloat(float, float)
|
||||||
* @since 3.5
|
* @since 3.5
|
||||||
*/
|
*/
|
||||||
public static float nextFloat() {
|
public static float nextFloat() {
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class RandomUtilsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests next double range, random result.
|
* Tests next int range, random result.
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testNextIntRandomResult() {
|
public void testNextIntRandomResult() {
|
||||||
|
|
Loading…
Reference in New Issue