PCG module

random_get

procedure · 2 overloadsSource

The next 32 random bits, advancing the state. Any u64 is a valid state, including 0.

The sequence is fixed by the state, so a seed reproduces it on every platform.

ExampleOpen in playground ↗
state: u64;
random_seed(*state, 42);
assert(state == 0x91778aed87ee5eb1); // seeding sets the state from the seed
assert(random_get(*state) == 0x75830bbd);
assert(random_get(*state) == 0x0e6dfdb2);
random_get :: (state: *u64) -> u32

Parameters

state: *u64

Returns

u32
random_get :: () -> u32

Returns

u32

See also