Add an f32() method to Rng.

This commit is contained in:
Nathan Vegdahl 2022-08-17 12:13:29 -07:00
parent f0e5d538b7
commit cb01d1aaea

View File

@ -58,6 +58,12 @@ impl Rng {
let t = (self.state as u128).wrapping_mul(self.state as u128 ^ 0xe7037ed1a0b428db); let t = (self.state as u128).wrapping_mul(self.state as u128 ^ 0xe7037ed1a0b428db);
((t >> 64) ^ t) as u64 ((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())
}
} }
//------------------------------------------------------------- //-------------------------------------------------------------