Skip to main content

unif_01

Function unif_01 

Source
pub fn unif_01(bits: impl FnMut() -> u64) -> f64
Expand description

Returns a random f64 distributed as a uniform real in [0 . . 1) rounded down to the nearest representable value: every float in [0 . . 1) is reachable, subnormals and 0 included, with probability equal to the measure of the reals that round down to it.

An alias for f64_full, the technique of choice; the rand feature provides the same conversion as a method (Unif01Ext::unif_01).

§Examples

let mut src = rand_float::sources::Weyl(42);
let x = rand_float::uniform::unif_01(|| src.next_u64());
assert!((0.0..1.0).contains(&x));