Class RandomNumbers
java.lang.Object
com.carrotsearch.randomizedtesting.generators.RandomNumbers
Utility classes for selecting random numbers from within a range or the
numeric domain for a given type.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic long
Similar toRandom.nextInt(int)
, but returns a long between 0 (inclusive) andn
(exclusive).static int
randomIntBetween
(Random r, int min, int max) A random integer betweenmin
(inclusive) andmax
(inclusive).static long
randomLongBetween
(Random r, long min, long max) A random long betweenmin
(inclusive) andmax
(inclusive).private static int
toIntExact
(long value)
-
Constructor Details
-
RandomNumbers
public RandomNumbers()
-
-
Method Details
-
randomIntBetween
A random integer betweenmin
(inclusive) andmax
(inclusive). -
randomLongBetween
A random long betweenmin
(inclusive) andmax
(inclusive). -
nextLong
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)
-