Skip to main content

rand_float/
sources.rs

1//! Trivial deterministic 64-bit generator.
2//!
3//! [`Weyl`] is not a recommended general-purpose generator: it has insufficient
4//! statistical quality for anything but feeding a benchmark or a test. It is
5//! here so that all conversion techniques can be driven by the same cheap,
6//! inlinable bit stream.
7
8/// A Weyl (additive) generator: the state advances by the golden-ratio
9/// constant 0x9E3779B97F4A7C15 and is returned as is.
10pub struct Weyl(pub u64);
11
12impl Weyl {
13    /// Returns the next 64-bit word of the sequence.
14    #[inline(always)]
15    pub fn next_u64(&mut self) -> u64 {
16        self.0 = self.0.wrapping_add(0x9E3779B97F4A7C15);
17        self.0
18    }
19}