Random module

random_get

procedure · 2 overloadsSource

The next 64 random bits, advancing the state. Without a state it draws from context.mcg_state.

All 64 bits are usable; take % n of the result for a small bound, remembering the slight bias that causes when n is not a power of two.

ExampleOpen in playground ↗
state: Random_State;
random_seed(*state, cast(u64) 42);
first := random_get(*state);

random_seed(*state, cast(u64) 42);
assert(random_get(*state) == first); // same seed, same stream
assert(random_get(*state) != first);
random_get :: (state: *Random_State) -> u64

Parameters

state: *Random_State

Returns

u64
random_get :: () -> u64

Returns

u64

See also