Skip to content

rand.constants #

Constants #

const lower_mask = u64(0x00000000FFFFFFFF)

Commonly used constants across RNGs - some taken from "Numerical Recipes".

const max_u32 = u32(0xFFFFFFFF)
const max_u64 = u64(0xFFFFFFFFFFFFFFFF)
const u31_mask = u32(0x7FFFFFFF)
const u63_mask = u64(0x7FFFFFFFFFFFFFFF)
const ieee754_mantissa_f32_mask = (u32(1) << 23) - 1

23 bits for f32

const ieee754_mantissa_f64_mask = (u64(1) << 52) - 1

52 bits for f64

const reciprocal_2_23rd = 1.0 / f64(u32(1) << 23)

smallest mantissa with exponent 0 (un normalized)

const reciprocal_2_52nd = 1.0 / f64(u64(1) << 52)