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.
More than one draw may be consumed, so the state afterwards depends on the bound.
state: u64;
random_seed(*state, 9);
counts: [6] int;
for 1..6000 counts[random_get_within_bound(*state, 6)] += 1;
for counts assert(it > 800 && it < 1200);random_get_within_bound :: (state: *u64, range: u32) -> u32
Parameters
- state: *u64
- range: u32
Returns
- u32
random_get_within_bound :: (bound: u32) -> u32
Parameters
- bound: u32
Returns
- u32