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

RandomgenerateRandomBySampleSeed(long sampleSeed, long fallbackValue)
Generate random instance according to sample seed.
if (sampleSeed != fallbackValue) {
    return new Random(sampleSeed);
return new Random();
longgenerateRandomLongValue()
generate Random Long Value
long randomID = generateRandomLongValue(MIN_SEED, Long.MAX_VALUE);
return randomID;
longgetLong()
Get next random long value.
return random.nextLong();
longgetLong()
Gets a random long.
return RANDOM.nextLong();
longgetLongBetween(long n, long m)
get Long Between
if (m <= n) {
    return n;
long res = getLongMoreThanZero();
return n + res % (m - n);
longgetLongInRange(long minValue, long maxValue)
It returns a long/Long value between min and max value (included).
return (long) (getDoubleInRange(minValue - 0.5, maxValue + 0.5 - (1 / Long.MAX_VALUE)) + 0.5);
longgetLongSpecial()
get Long Special
int i = rng.nextInt();
long j = rng.nextLong();
if ((i & 0x10) != 0)
    return j;
return lspecial[((int) j & 0x7fffffff) % special.length] * ((i & 0x20) == 0 ? 1 : -1) + ((i & 0x03) - 1);
long[]getLongSpecialCases()
Testing helper method.
long longs[] = new long[100];
int i = 0;
longs[i++] = Long.MAX_VALUE;
longs[i++] = Long.MAX_VALUE - 1L;
longs[i++] = (long) Integer.MAX_VALUE + 1L;
longs[i++] = Integer.MAX_VALUE;
longs[i++] = Integer.MAX_VALUE - 1;
longs[i++] = 100L;
...
longgetRandomLong()
Generates next random long
Random rand = new Random(System.currentTimeMillis());
return rand.nextLong();
doublenextLong()
next Long
return random.nextDouble();