std.rand
xorshift64* prng; same seed, same sequence; not for crypto
pub Rng :: struct { state: u64,}pub seed :: fn(s: u64) -> Rnggenerator from a seed; 0 is remapped to a valid state
next_u64
Section titled “next_u64”pub next_u64 :: fn(self: *Rng) -> u64next raw u64; advances the state
next_u32
Section titled “next_u32”pub next_u32 :: fn(self: *Rng) -> u32next_f32
Section titled “next_f32”pub next_f32 :: fn(self: *Rng) -> f32float in [0, 1), 24-bit mantissa
range_i32
Section titled “range_i32”pub range_i32 :: fn(self: *Rng, lo: i32, hi: i32) -> i32uniform int in [lo, hi); lo if empty
range_f32
Section titled “range_f32”pub range_f32 :: fn(self: *Rng, lo: f32, hi: f32) -> f32float in [lo, hi)
chance
Section titled “chance”pub chance :: fn(self: *Rng, p: f32) -> booltrue with probability p, clamped to 0..1
pub sign :: fn(self: *Rng) -> f32-1 or +1
pub below :: fn(self: *Rng, n: u64) -> u64uniform int in [0, n), unbiased (rejection); 0 if n is 0
range_u64
Section titled “range_u64”pub range_u64 :: fn(self: *Rng, lo: u64, hi: u64) -> u64uniform int in [lo, hi); lo if empty
next_f64
Section titled “next_f64”pub next_f64 :: fn(self: *Rng) -> f64float in [0, 1), 53-bit mantissa
fill_bytes
Section titled “fill_bytes”pub fill_bytes :: fn(self: *Rng, out: []u8)shuffle
Section titled “shuffle”pub shuffle :: fn($T: type, self: *Rng, xs: []T)uniform shuffle, fisher-yates
choose
Section titled “choose”pub choose :: fn($T: type, self: *Rng, xs: []const T) -> ?Tuniform pick; null if empty