/** * <p>Returns the next pseudorandom, uniformly distributed long value * from the Math.random() sequence.</p> * Identical to <code>nextLong(Long.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random long */ public long nextLong() { return nextLong(Long.MAX_VALUE); }
/** * <p>Returns a pseudorandom, uniformly distributed long value between * <code>0</code> (inclusive) and the specified value (exclusive), from * the Math.random() sequence.</p> * * @param n the specified exclusive max-value * @return the random long * @throws IllegalArgumentException when <code>n <= 0</code> */ public static long nextLong(long n) { if (n <= 0) { throw new IllegalArgumentException( "Upper bound for nextInt must be positive" ); } // Code adapted from Harmony Random#nextInt(int) if ((n & -n) == n) { // n is power of 2 // dropping lower order bits improves behaviour for low values of n return next63bits() >> 63 // drop all the bits - bitsRequired(n-1); // except the ones we need } // Not a power of two long val; long bits; do { // reject some values to improve distribution bits = next63bits(); val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
/** * <p>Returns the next pseudorandom, uniformly distributed int value * from the Math.random() sequence.</p> * Identical to <code>nextInt(Integer.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random int */ public int nextInt() { return nextInt(Integer.MAX_VALUE); }
/** * <p>Returns a pseudorandom, uniformly distributed long value between * <code>0</code> (inclusive) and the specified value (exclusive), from * the Math.random() sequence.</p> * * @param n the specified exclusive max-value * @return the random long * @throws IllegalArgumentException when <code>n <= 0</code> */ public static long nextLong(long n) { if (n <= 0) { throw new IllegalArgumentException( "Upper bound for nextInt must be positive" ); } // Code adapted from Harmony Random#nextInt(int) if ((n & -n) == n) { // n is power of 2 // dropping lower order bits improves behaviour for low values of n return next63bits() >> 63 // drop all the bits - bitsRequired(n-1); // except the ones we need } // Not a power of two long val; long bits; do { // reject some values to improve distribution bits = next63bits(); val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
/** * <p>Returns the next pseudorandom, uniformly distributed long value * from the Math.random() sequence.</p> * Identical to <code>nextLong(Long.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random long */ public long nextLong() { return nextLong(Long.MAX_VALUE); }
/** * <p>Returns the next pseudorandom, uniformly distributed int value * from the Math.random() sequence.</p> * Identical to <code>nextInt(Integer.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random int */ public int nextInt() { return nextInt(Integer.MAX_VALUE); }
/** * <p>Returns a pseudorandom, uniformly distributed long value between * <code>0</code> (inclusive) and the specified value (exclusive), from * the Math.random() sequence.</p> * * @param n the specified exclusive max-value * @return the random long * @throws IllegalArgumentException when <code>n <= 0</code> */ public static long nextLong(long n) { if (n <= 0) { throw new IllegalArgumentException( "Upper bound for nextInt must be positive" ); } // Code adapted from Harmony Random#nextInt(int) if ((n & -n) == n) { // n is power of 2 // dropping lower order bits improves behaviour for low values of n return next63bits() >> 63 // drop all the bits - bitsRequired(n-1); // except the ones we need } // Not a power of two long val; long bits; do { // reject some values to improve distribution bits = next63bits(); val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
/** * <p>Returns the next pseudorandom, uniformly distributed long value * from the Math.random() sequence.</p> * Identical to <code>nextLong(Long.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random long */ public long nextLong() { return nextLong(Long.MAX_VALUE); }
/** * <p>Returns the next pseudorandom, uniformly distributed int value * from the Math.random() sequence.</p> * Identical to <code>nextInt(Integer.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random int */ public int nextInt() { return nextInt(Integer.MAX_VALUE); }
/** * <p>Returns a pseudorandom, uniformly distributed long value between * <code>0</code> (inclusive) and the specified value (exclusive), from * the Math.random() sequence.</p> * * @param n the specified exclusive max-value * @return the random long * @throws IllegalArgumentException when <code>n <= 0</code> */ public static long nextLong(long n) { if (n <= 0) { throw new IllegalArgumentException( "Upper bound for nextInt must be positive" ); } // Code adapted from Harmony Random#nextInt(int) if ((n & -n) == n) { // n is power of 2 // dropping lower order bits improves behaviour for low values of n return next63bits() >> 63 // drop all the bits - bitsRequired(n-1); // except the ones we need } // Not a power of two long val; long bits; do { // reject some values to improve distribution bits = next63bits(); val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
/** * <p>Returns the next pseudorandom, uniformly distributed long value * from the Math.random() sequence.</p> * Identical to <code>nextLong(Long.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random long */ public long nextLong() { return nextLong(Long.MAX_VALUE); }
/** * <p>Returns the next pseudorandom, uniformly distributed int value * from the Math.random() sequence.</p> * Identical to <code>nextInt(Integer.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random int */ public int nextInt() { return nextInt(Integer.MAX_VALUE); }
/** * <p>Returns a pseudorandom, uniformly distributed long value between * <code>0</code> (inclusive) and the specified value (exclusive), from * the Math.random() sequence.</p> * * @param n the specified exclusive max-value * @return the random long * @throws IllegalArgumentException when <code>n <= 0</code> */ public static long nextLong(long n) { if (n <= 0) { throw new IllegalArgumentException( "Upper bound for nextInt must be positive" ); } // Code adapted from Harmony Random#nextInt(int) if ((n & -n) == n) { // n is power of 2 // dropping lower order bits improves behaviour for low values of n return next63bits() >> 63 // drop all the bits - bitsRequired(n-1); // except the ones we need } // Not a power of two long val; long bits; do { // reject some values to improve distribution bits = next63bits(); val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
/** * <p>Returns the next pseudorandom, uniformly distributed long value * from the Math.random() sequence.</p> * Identical to <code>nextLong(Long.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random long */ public long nextLong() { return nextLong(Long.MAX_VALUE); }
/** * <p>Returns the next pseudorandom, uniformly distributed int value * from the Math.random() sequence.</p> * Identical to <code>nextInt(Integer.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random int */ public int nextInt() { return nextInt(Integer.MAX_VALUE); }
/** * <p>Returns a pseudorandom, uniformly distributed long value between * <code>0</code> (inclusive) and the specified value (exclusive), from * the Math.random() sequence.</p> * * @param n the specified exclusive max-value * @return the random long * @throws IllegalArgumentException when <code>n <= 0</code> */ public static long nextLong(long n) { if (n <= 0) { throw new IllegalArgumentException( "Upper bound for nextInt must be positive" ); } // Code adapted from Harmony Random#nextInt(int) if ((n & -n) == n) { // n is power of 2 // dropping lower order bits improves behaviour for low values of n return next63bits() >> 63 // drop all the bits - bitsRequired(n-1); // except the ones we need } // Not a power of two long val; long bits; do { // reject some values to improve distribution bits = next63bits(); val = bits % n; } while (bits - val + (n - 1) < 0); return val; }
/** * <p>Returns the next pseudorandom, uniformly distributed long value * from the Math.random() sequence.</p> * Identical to <code>nextLong(Long.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random long */ public long nextLong() { return nextLong(Long.MAX_VALUE); }
/** * <p>Returns the next pseudorandom, uniformly distributed int value * from the Math.random() sequence.</p> * Identical to <code>nextInt(Integer.MAX_VALUE)</code> * <p> * <b>N.B. All values are >= 0.<b> * </p> * @return the random int */ public int nextInt() { return nextInt(Integer.MAX_VALUE); }
when(mockedRandom.nextLong()).thenAnswer(invocation -> (currentValue++));