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
.
Trait Implementations§
impl Copy for Rand64
impl Eq for Rand64
impl StructuralPartialEq for Rand64
Auto Trait Implementations§
impl Freeze for Rand64
impl RefUnwindSafe for Rand64
impl Send for Rand64
impl Sync for Rand64
impl Unpin for Rand64
impl UnwindSafe for Rand64
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes