std/numeric/random
std/random — pseudorandom number generation.
The API is the global RNG: nextI32 / nextI64 / nextF64 /nextBool / nextRange consume from a process-wide xoshiro256
state seeded once at first use from the OS CSPRNG, falling back to
the wall clock. Not the monotonic clock: its origin is set by the
first read, so it would yield near-zero and near-constant across
runs — and this seed keys HashMap bucket order.
Free functions
| Type | Method and description |
|---|---|
| seed(seedValue : i64) : void Reseeds the process-wide xoshiro256 stream so subsequent draws are reproducible. Pass a fixed value for deterministic test runs. |
| nextI32() : i32 Next uniform i32 over the full i32 range. |
| nextI64() : i64 Next uniform i64 over the full i64 range. |
| nextF64() : f64 Next uniform f64 in [0.0, 1.0). |
| nextBool() : bool Next bool, true or false with equal probability. |
| nextRangeI32(min : i32, max : i32) : i32 Next uniform i32 in the half-open range [min, max). Returns minunchanged when max <= min. |
| nextRangeI64(min : i64, max : i64) : i64 Next uniform i64 in the half-open range [min, max). Returns minunchanged when max <= min. |
Method detail
#seed
Reseeds the process-wide xoshiro256 stream so subsequent draws are
reproducible. Pass a fixed value for deterministic test runs.
seedValue the new seed for the xoshiro256 stream#nextI32
Next uniform i32 over the full i32 range.
#nextI64
Next uniform i64 over the full i64 range.
#nextF64
Next uniform f64 in [0.0, 1.0).
#nextBool
Next bool, true or false with equal probability.
#nextRangeI32
Next uniform i32 in the half-open range [min, max). Returns min
unchanged when max <= min.
min inclusive lower boundmax exclusive upper bound#nextRangeI64
Next uniform i64 in the half-open range [min, max). Returns min
unchanged when max <= min.
min inclusive lower boundmax exclusive upper boundC class Random
Same process-wide stream as the free functions above; the
class exists to make Random::nextI32() reachable without an
explicit use std::numeric::random::nextI32. There is a single
process-wide stream rather than per-instance RNG state.
Methods
| Type | Method and description |
|---|---|
| seed(seedValue : i64) : void |
| nextI32() : i32 |
| nextI64() : i64 |
| nextF64() : f64 |
| nextBool() : bool |
| nextRangeI32(min : i32, max : i32) : i32 |
| nextRangeI64(min : i64, max : i64) : i64 |