Struct xorshift128plus::XorShift128Plus
[−]
[src]
pub struct XorShift128Plus(_, _);
Examples
Construct a RNG from an integer.
extern crate xorshift128plus; use xorshift128plus::XorShift128Plus; let mut rng = XorShift128Plus::from_u32(4293262078); println!("First random float: {}", rng.next()); println!("Second random float: {}", rng.next());
You can also construct a RNG by supplying 16 bytes of raw data. Here we are using the rand
crates rand::random
to generate 16 bytes
of random data to use as the initial seed. This data could also come from a file, a database or
anywhere else really.
extern crate rand; extern crate xorshift128plus; use xorshift128plus::XorShift128Plus; let seed: [u8; 16] = rand::random(); let mut rng = XorShift128Plus::from_bytes(seed); println!("First random float: {}", rng.next()); println!("Second random float: {}", rng.next());
Methods
impl XorShift128Plus
[src]
fn from_bytes(seed: [u8; 16]) -> XorShift128Plus
Constructs a new RNG with the seed specified as 16 bytes of raw data.
fn from_u32(seed: u32) -> XorShift128Plus
Constructs a new RNG with the seed specified as a unsigned 32bit integer. Note that this seeding is suboptimal since it will only contain 32 bits of entropy instead of 128 bits.
fn from_u64(seed: u64) -> XorShift128Plus
Constructs a new RNG with the seed specified as a unsigned 64bit integer. Note that this seeding is suboptimal since it will only contain 64 bits of entropy instead of 128 bits.
fn next(&mut self) -> f64
Returns the next psuedo-random number between 0 (inclusivly) and 1 (exclusivly).