math::random +linux +x86_64

math::random provides a pseudorandom number generator, which yields a deterministic sequence of psuedo-random numbers based on a seed value.

Beware! This module is NOT suitable for generating genuinely random data for cryptographic use. See crypto::random for cryptographically secure random number generation.



type random;


fn f64rand(*random) f64;
fn init(u64) random;
fn next(*random) u64;
fn u32n(*random, u32) u32;
fn u64n(*random, u64) u64;


type random[link]

type random = u64;

State for a pseudorandom number generator.


fn f64rand[link]

fn f64rand(r: *random) f64;

Returns a pseudo-random 64-bit floating-point number in the interval [0.0, 1.0)

fn init[link]

fn init(seed: u64) random;

Initializes a pseudorandom number generator with a given seed. This seed will yield the same sequence of psuedo-random numbers if used again.

fn next[link]

fn next(r: *random) u64;

Returns a psuedo-random 64-bit unsigned integer.

fn u32n[link]

fn u32n(r: *random, n: u32) u32;

Returns a pseudo-random 32-bit unsigned integer in the half-open interval [0,n).

fn u64n[link]

fn u64n(r: *random, n: u64) u64;

Returns a pseudo-random 64-bit unsigned integer in the half-open interval [0,n).