Class RandomNumbers

java.lang.Object
com.carrotsearch.randomizedtesting.generators.RandomNumbers

public final class RandomNumbers extends Object
Utility classes for selecting random numbers from within a range or the numeric domain for a given type.
See Also:
  • Constructor Details

    • RandomNumbers

      public RandomNumbers()
  • Method Details

    • randomIntBetween

      public static int randomIntBetween(Random r, int min, int max)
      A random integer between min (inclusive) and max (inclusive).
    • randomLongBetween

      public static long randomLongBetween(Random r, long min, long max)
      A random long between min (inclusive) and max (inclusive).
    • nextLong

      public static long nextLong(Random rnd, long n)
      Similar to Random.nextInt(int), but returns a long between 0 (inclusive) and n (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)