A small 32-bit-output permuted congruential generator (XSH-RR) over a 64-bit state.
Each procedure comes in two forms: one that takes the state as a *u64 you own, and one without a state
that uses a single module-global u64. The global is shared by every thread and is not locked, so use
your own state when more than one thread draws. The global starts at a fixed value, so an unseeded program
sees the same numbers every run. The generator is not suitable for cryptography.
The next 32 random bits, advancing the state. Any u64 is a valid state, including 0.
state: u64;
random_seed(*state, 42);
assert(state == 0x91778aed87ee5eb1); // seeding sets the state from the seedassert(random_get(*state) == 0x75830bbd);
assert(random_get(*state) == 0x0e6dfdb2);
A value in [0, bound) without modulo bias, drawn by rejecting the few low outputs that would make some results likelier. bound must not be 0 (an assert fails); with bound 1 the result is always 0.
Starts the generator from new_seed: the state becomes seed * 6364136223846793005 + 1442695040888963407 (wrapping), so the first draw comes from that value. Equal seeds give equal sequences.
A float between min and max, interpolated from random_get_zero_to_one. The result is clamped into the range (so max itself can occur); equal bounds give that value.