math::random+x86_64 +linux

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.

Index

Types

type random = u64;

Functions

fn f64rand(r: *random) f64;
fn init(seed: u64) random;
fn next(r: *random) u64;
fn u32n(r: *random, n: u32) u32;
fn u64n(r: *random, n: u64) u64;

Types

type random[link]

type random = u64;

State for a pseudorandom number generator.

Functions

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). n must be greater than zero.

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). n must be greater than zero.