Random module

random_get_zero_to_one

procedure · 2 overloadsSource

A float in [0, 1], both ends possible, from 24 random bits divided by 2^24 - 1. The values are evenly spaced, 24 bits of resolution.

Use random_get_zero_to_one_open when 1 must not occur, for example to index an array with cast(int) (r * count).

ExampleOpen in playground ↗
state: Random_State;
random_seed(*state, cast(u64) 1);
for 1..1000 {
    r := random_get_zero_to_one(*state);
    assert(r >= 0 && r <= 1);
}
random_get_zero_to_one :: (state: *Random_State) -> float

Parameters

state: *Random_State

Returns

float
random_get_zero_to_one :: () -> float

Returns

float

See also