Function std.math.frexp
Separate floating point value
into significand and exponent.
Prototype
T frexp(T)( T value, int exp ) pure nothrow @nogc @trusted if (isFloatingPoint!T);
Returns
Calculate and return x and exp
such that
value
=x*2exp
and
.5 <= |x| < 1.0
x has same sign as value
.
value
exp
Example
int exp; real mantissa = frexp(123.456L, exp); // check if values are equal to 19 decimal digits of precision assert(equalsDigit(mantissa * pow(2.0L, cast(real)exp), 123.456L, 19)); 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);
Authors
Walter Bright, Don Clugston, Conversion of CEPHES math library to D by Iain Buclaw