Calculate and return x and exp such that value =x*2exp and .5 <= |x| < 1.0
x has same sign as value.
value | returns | exp |
---|---|---|
±0.0 | ±0.0 | 0 |
+∞ | +∞ | int.max |
-∞ | -∞ | int.min |
±NaN | ±NaN | int.min |
import std.math.operations : isClose; int exp; real mantissa = frexp(123.456L, exp); assert(isClose(mantissa * pow(2.0L, cast(real) exp), 123.456L)); assert(frexp(-real.nan, exp) && exp == int.min); assert(frexp(real.nan, exp) && exp == int.min); assert(frexp(-real.infinity, exp) == -real.infinity && exp == int.min); assert(frexp(real.infinity, exp) == real.infinity && exp == int.max); assert(frexp(-0.0, exp) == -0.0 && exp == 0); assert(frexp(0.0, exp) == 0.0 && exp == 0);
Separate floating point value into significand and exponent.