def f53

bend-collections-laws-math@1.0.0.0 · src/math/random/rand.bend:226

import bend-collections-laws-math@1.0.0.0/src/math/random/rand.bend as Rand
import Base
import bend-collections-laws-math@1.0.0.0/src/math/u64.bend as W
import bend-collections-laws-math@1.0.0.0/src/math/w64.bend as X
import bend-collections-laws-math@1.0.0.0/src/math/f64.bend as F

226# x >> 11 as a double divided by 2^53: for m = x >> 11 > 0 with c leading
227# zeros (11 <= c <= 63), m << (c - 11) has its top bit at 52, and the value
228# m 2^-53 is that significand with biased exponent 1033 - c (below 1023)
229def f53(+m: W.U64, +c: Nat) -> F.F64:
230  F.Bits{X.lo(X.shl(m, Nat.sub(c, 11n))), U32.add(U32.mul(U32.from_nat(Nat.sub(1033n, c)), 1048576), U32.and(X.hi(X.shl(m, Nat.sub(c, 11n))), 1048575))}

Uses (11)

Used by (7)