Axle v0.14.1
Package

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

TypeMethod and description
void
seed(seedValue : i64) : void Reseeds the process-wide xoshiro256 stream so subsequent draws are
reproducible. Pass a fixed value for deterministic test runs.
i32
nextI32() : i32 Next uniform i32 over the full i32 range.
i64
nextI64() : i64 Next uniform i64 over the full i64 range.
f64
nextF64() : f64 Next uniform f64 in [0.0, 1.0).
bool
nextBool() : bool Next bool, true or false with equal probability.
i32
nextRangeI32(min : i32, max : i32) : i32 Next uniform i32 in the half-open range [min, max). Returns min
unchanged when max <= min.
i64
nextRangeI64(min : i64, max : i64) : i64 Next uniform i64 in the half-open range [min, max). Returns min
unchanged when max <= min.

Method detail

#seed

seed(seedValue : i64) : void

Reseeds the process-wide xoshiro256 stream so subsequent draws are
reproducible. Pass a fixed value for deterministic test runs.

Parameters
seedValue the new seed for the xoshiro256 stream

#nextI32

nextI32() : i32

Next uniform i32 over the full i32 range.

#nextI64

nextI64() : i64

Next uniform i64 over the full i64 range.

#nextF64

nextF64() : f64

Next uniform f64 in [0.0, 1.0).

#nextBool

nextBool() : bool

Next bool, true or false with equal probability.

#nextRangeI32

nextRangeI32(min : i32, max : i32) : i32

Next uniform i32 in the half-open range [min, max). Returns min
unchanged when max <= min.

Parameters
min inclusive lower bound
max exclusive upper bound

#nextRangeI64

nextRangeI64(min : i64, max : i64) : i64

Next uniform i64 in the half-open range [min, max). Returns min
unchanged when max <= min.

Parameters
min inclusive lower bound
max exclusive upper bound

C 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

Method detail

#seed

seed(seedValue : i64) : void

#nextI32

nextI32() : i32

#nextI64

nextI64() : i64

#nextF64

nextF64() : f64

#nextBool

nextBool() : bool

#nextRangeI32

nextRangeI32(min : i32, max : i32) : i32

#nextRangeI64

nextRangeI64(min : i64, max : i64) : i64