the next bits (1 to 32) pseudorandom bits; a 32-bit draw is signed, as in Java
a double in [0, 1) from 53 random bits
a float in [0, 1) from 24 random bits
With no argument, any int (nextInt()); with a positive bound, an int in
[0, bound) (nextInt(bound)), drawn without modulo bias the way Java does.
Optionalbound: numbera signed 64-bit integer, two 32-bit draws combined as Java does
restarts the sequence, as Random.setSeed does
The 48-bit linear congruential generator behind
java.util.Random, bit for bit, so a game ported from the JVM can replay the same seed and get the same dungeon. The algorithm is the one the Java documentation specifies; every method below follows that specification, including the rejection loop ofnextInt(bound).Not a good general generator (use
Generatorfor that): its only job is to agree with Java. Seeds may be numbers or bigints; a 64-bit seed keeps its low 48 bits after the documented scramble.Example