File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -148,9 +148,14 @@ impl Rng {
148
148
/// Generates a random `u64`.
149
149
#[ inline]
150
150
fn gen_u64 ( & mut self ) -> u64 {
151
- let s = self . 0 . wrapping_add ( 0xA0761D6478BD642F ) ;
151
+ // Constants for WyRand taken from: https://github.com/wangyi-fudan/wyhash/blob/master/wyhash.h#L151
152
+ // Updated for the final v4.2 implementation with improved constants for better entropy output.
153
+ const WY_CONST_0 : u64 = 0x2d35_8dcc_aa6c_78a5 ;
154
+ const WY_CONST_1 : u64 = 0x8bb8_4b93_962e_acc9 ;
155
+
156
+ let s = self . 0 . wrapping_add ( WY_CONST_0 ) ;
152
157
self . 0 = s;
153
- let t = u128:: from ( s) * u128:: from ( s ^ 0xE7037ED1A0B428DB ) ;
158
+ let t = u128:: from ( s) * u128:: from ( s ^ WY_CONST_1 ) ;
154
159
( t as u64 ) ^ ( t >> 64 ) as u64
155
160
}
156
161
You can’t perform that action at this time.
0 commit comments