Splits a float64 into a fraction and a power of two, x = fraction * 2^exponent with abs(fraction) in [0.5, 1). Zero, infinities and NaN come back unchanged with exponent 0. Subnormals are handled.
m, e := frexp(cast(float64) 8);
assert(m == 0.5 && e == 4);
m, e = frexp(cast(float64) -0.75);
assert(m == -0.75 && e == 0);frexp :: (x: float64) -> (result: float64, pow2: s32)
Splits x into a fraction in 0.5..1 (same sign) and a power of two, so x is result * 2^pow2. Zero, infinity and NaN come back unchanged with a power of 0.
Parameters
- x: float64
- the value to split.
Returns
- result: float64
- pow2: s32