We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6ce90e4 commit e84a7eaCopy full SHA for e84a7ea
necsim-impls-no-std/src/rng/wyrng.rs
@@ -6,10 +6,11 @@ pub struct WyRng(WyRand);
6
#[contract_trait]
7
impl necsim_core::rng::Core for WyRng {
8
fn sample_uniform(&mut self) -> f64 {
9
+ // U(0.0, 1.0) generation from:
10
+ // http://prng.di.unimi.it -> Generating uniform doubles in the unit interval
11
#[allow(clippy::cast_precision_loss)]
- (self.0.generate_range(0_u64, u64::MAX) as f64)
- / #[allow(clippy::cast_precision_loss)]
12
- (u64::MAX as f64)
+ ((self.0.generate::<u64>() >> 11) as f64)
13
+ * f64::from_bits(0x3CA0_0000_0000_0000_u64) //0x1.0p-53
14
}
15
16
0 commit comments