Skip to main content

Module random

Module random 

Source
Expand description

Random Number Generation

Provides random number generation using thread-local RNG with cryptographically secure seeding from system entropy.

§Thread Safety

Uses thread-local RNG via rand::thread_rng(). Each thread gets its own independent RNG instance, so this is safe to call from any thread without synchronization.

§Platform Support

  • Native: Uses system entropy for seeding (getrandom)
  • WASM: Not available (module not compiled for wasm32)

§Example

use logicaffeine_system::random;

let dice_roll = random::randomInt(1, 6);
assert!((1..=6).contains(&dice_roll));

let probability = random::randomFloat();
assert!((0.0..1.0).contains(&probability));

Functions§

randomFloat
Generates a random floating-point number.
randomInt
Generates a random integer in an inclusive range.