def frexp

bend-collections-laws-crypto@1.0.0.0 · spec/math/f64.bend:412

import bend-collections-laws-crypto@1.0.0.0/spec/math/f64.bend as F64
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/f64.bend as F
import bend-collections-laws-crypto@1.0.0.0/src/math/natural.bend as M

412# (m, e) with x = m 2^e and 1/2 <= |m| < 1: m is mant(x) scaled by
413# 2^-bit_length(mant(x)) (exact), e the rest of the scale; NaN gives (NaN, 0),
414# zeros and infinities (x, 0) (4.4)
415def frexp(+x: F.F64) -> F.F64 & F.Exp:
416  pickt(F.F64 & F.Exp, is_nan(x), (qnan(), F.Exp{False{}, 0n}), pickt(F.F64 & F.Exp, Bool.or(is_inf(x), is_zero(x)), (x, F.Exp{False{}, 0n}), (round(sign(x), mant(x), Nat.sub(zb(), M.bit_length(mant(x)))), exp_of(Nat.add(xexp(x), M.bit_length(mant(x)))))))

Uses (20)

Used by (1)