File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -94,22 +94,22 @@ impl extensions for rng {
94
94
( self . next ( ) as u64 << 32 ) | self . next ( ) as u64
95
95
}
96
96
97
- /// Return a random float
97
+ /// Return a random float in the interval [0,1]
98
98
fn gen_float ( ) -> float {
99
99
self . gen_f64 ( ) as float
100
100
}
101
101
102
- /// Return a random f32
102
+ /// Return a random f32 in the interval [0,1]
103
103
fn gen_f32 ( ) -> f32 {
104
104
self . gen_f64 ( ) as f32
105
105
}
106
106
107
- /// Return a random f64
107
+ /// Return a random f64 in the interval [0,1]
108
108
fn gen_f64 ( ) -> f64 {
109
109
let u1 = self . next ( ) as f64 ;
110
110
let u2 = self . next ( ) as f64 ;
111
111
let u3 = self . next ( ) as f64 ;
112
- let scale = u32:: max_value as f64 ;
112
+ const scale : f64 = ( u32:: max_value as f64 ) + 1.0f64 ;
113
113
ret ( ( u1 / scale + u2) / scale + u3) / scale;
114
114
}
115
115
You can’t perform that action at this time.
0 commit comments