Java Utililty Methods Random Long

List of utility methods to do Random Long

Description

The list of methods to do Random Long are organized into topic(s).

Method

longnextLong()
Generates a random long which is used as a dummy market id
long bits, val;
do {
    bits = (random.nextLong() << 1) >>> 1;
    val = bits % 10000000000000L;
} while (bits - val + (10000000000000L - 1) < 0L);
return val + 30000000000000L;
longnextLong()
next Long
return RANDOM.nextLong();
longnextLong(long n)
Returns random long within the bounds of 0 and n.
long bits, val;
do {
    bits = (rand.nextLong() << 1) >>> 1;
    val = bits % n;
} while (bits - val + (n - 1) < 0L);
return val;
longnextLong(long n)
next Long
if (n <= 0) {
    throw new IllegalArgumentException("n must be positive");
long bits, val;
do {
    bits = _rnd.nextInt();
    val = bits % n;
} while (bits - val + (n - 1) < 0);
...
longnextLong(long RangeBottom, long rangeTop)
next Long
return RangeBottom + ((long) (rnd.nextDouble() * (rangeTop - RangeBottom)));
longnextLong(Random random, final long lower, final long upper)
Generates a uniformly distributed random long integer between lower and upper (endpoints included).
if (lower == upper)
    return lower;
if (lower > upper)
    throw new IllegalArgumentException();
final long max = (upper - lower) + 1;
if (max <= 0) {
    while (true) {
        final long r = random.nextLong();
...
longnextLong(Random rng, long n)
Returns a random long
if (n <= 0)
    throw new IllegalArgumentException("n must be positive");
if ((n & -n) == n) 
    return (long) ((n * (long) rng.nextInt(31)) >> 31);
long bits, val;
do {
    bits = (rng.nextLong() << 1) >>> 1;
    val = bits % n;
...
longnextLong(Random rng, long n)
next Long
long bits, val;
do {
    bits = (rng.nextLong() << 1) >>> 1;
    val = bits % n;
} while (bits - val + (n - 1) < 0L);
return val;
LongnextLongId()
next Long Id
return RANDOM.nextLong() + 1;
longrandLong()
Returns the next pseudo random, uniformly distributed long value.
return generator.nextLong();