pub struct Rand64 { /* private fields */ }Expand description
A PRNG producing a 64-bit output.
The current implementation is PCG-XSH-RR.
Implementations§
Source§impl Rand64
impl Rand64
Sourcepub const DEFAULT_INC: u128 = 63_641_362_238_467_930_051_442_695_040_888_963_407u128
pub const DEFAULT_INC: u128 = 63_641_362_238_467_930_051_442_695_040_888_963_407u128
The default value for increment.
The value used here is from the PCG default C implementation: http://www.pcg-random.org/download.html
Sourcepub fn state(&self) -> (u128, u128)
pub fn state(&self) -> (u128, u128)
Returns the internal state of the PRNG. This allows you to save a PRNG and create a new one that will resume from the same spot in the sequence.
Sourcepub fn from_state(state: (u128, u128)) -> Self
pub fn from_state(state: (u128, u128)) -> Self
Creates a new PRNG from a saved state from Rand32::state().
This is NOT quite the same as new_inc() because new_inc() does
a little extra setup work to initialize the state.
Sourcepub fn rand_float(&mut self) -> f64
pub fn rand_float(&mut self) -> f64
Produces a random f64 in the range [0.0, 1.0).
Sourcepub fn rand_range(&mut self, range: Range<u64>) -> u64
pub fn rand_range(&mut self, range: Range<u64>) -> u64
Produces a random within the given bounds. Like any Range,
it includes the lower bound and excludes the upper one.
This should be faster than Self::rand() % end + start, but the
real advantage is it’s more convenient. Requires that
range.end <= range.start.