Add an f32() method to Rng.
This commit is contained in:
parent
f0e5d538b7
commit
cb01d1aaea
|
@ -58,6 +58,12 @@ impl Rng {
|
|||
let t = (self.state as u128).wrapping_mul(self.state as u128 ^ 0xe7037ed1a0b428db);
|
||||
((t >> 64) ^ t) as u64
|
||||
}
|
||||
|
||||
/// Returns a random f32 in [0.0, 1.0).
|
||||
#[inline(always)]
|
||||
pub fn f32(&mut self) -> f32 {
|
||||
u32_to_f32_norm(self.u32())
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user