Skip to main content

rand

Macro rand 

Source
macro_rules! rand {
    (xor32i; $min:expr, $max:expr) => { ... };
    (xor32f; $min:expr, $max:expr) => { ... };
    (mt32i; $min:expr, $max:expr) => { ... };
    (mt32f; $min:expr, $max:expr) => { ... };
    (pcg32i; $min:expr, $max:expr) => { ... };
    (pcg32f; $min:expr, $max:expr) => { ... };
    (philox32i; $min:expr, $max:expr) => { ... };
    (philox32f; $min:expr, $max:expr) => { ... };
    (tgfsr32i; $min:expr, $max:expr) => { ... };
    (tgfsr32f; $min:expr, $max:expr) => { ... };
    (xor64i; $min:expr, $max:expr) => { ... };
    (xor64f; $min:expr, $max:expr) => { ... };
    (mt64i; $min:expr, $max:expr) => { ... };
    (mt64f; $min:expr, $max:expr) => { ... };
    (philox64i; $min:expr, $max:expr) => { ... };
    (philox64f; $min:expr, $max:expr) => { ... };
    (xor128i; $min:expr, $max:expr) => { ... };
    (xor128f; $min:expr, $max:expr) => { ... };
}
Expand description

Generates a random value in the specified range using the specified algorithm and output type.

Seeds are automatically generated from the system time.

The argument format is [algorithm][bits][type].

  • type: i for signed integer [min, max], f for floating-point [min, max).

ยงExamples

use urng::rand;

let val_i32 = rand!(xor32i; 1, 100);
let val_f64 = rand!(mt64f; 0.5, 1.5);