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.

Index

Types

type random;

Functions

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

Types

type random[link]

type random = u64;

State for a pseudorandom number generator.

Functions

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).