Class RandomNumbers
- java.lang.Object
-
- com.carrotsearch.randomizedtesting.generators.RandomNumbers
-
public final class RandomNumbers extends java.lang.ObjectUtility classes for selecting random numbers from within a range or the numeric domain for a given type.- See Also:
BiasedNumbers
-
-
Constructor Summary
Constructors Constructor Description RandomNumbers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static longnextLong(java.util.Random rnd, long n)Similar toRandom.nextInt(int), but returns a long between 0 (inclusive) andn(exclusive).static intrandomIntBetween(java.util.Random r, int min, int max)A random integer betweenmin(inclusive) andmax(inclusive).static longrandomLongBetween(java.util.Random r, long min, long max)A random long betweenmin(inclusive) andmax(inclusive).private static inttoIntExact(long value)
-
-
-
Method Detail
-
randomIntBetween
public static int randomIntBetween(java.util.Random r, int min, int max)A random integer betweenmin(inclusive) andmax(inclusive).
-
randomLongBetween
public static long randomLongBetween(java.util.Random r, long min, long max)A random long betweenmin(inclusive) andmax(inclusive).
-
nextLong
public static long nextLong(java.util.Random rnd, long n)Similar toRandom.nextInt(int), but returns a long between 0 (inclusive) andn(exclusive).- Parameters:
rnd- Random generator.n- the bound on the random number to be returned. Must be positive.- Returns:
- Returns a random number between 0 and n-1.
-
toIntExact
private static int toIntExact(long value)
-
-