quantexp

Returns the exponent encoded into the specified _decimal value;

int
quantexp
(
D
)
(
auto const ref D x
)

Throws

InvalidOperationExceptionx is NaN or ±∞

Special values

xquantexp(x)
NaNint.min
±∞int.min

Notes: Unlike frexp where the exponent is calculated for a |coefficient| < 1.0, this functions returns the raw encoded exponent.

Examples

auto d = decimal32("0x0001p+12"); //1 * 10^^12
auto z = decimal64("0x0000p-3");  //0 * 10^^-3

int calculatedExponent, rawExponent;

//d is 0.1 * 10^^13
frexp(d, calculatedExponent);
rawExponent = quantexp(d);
assert (calculatedExponent == 13  && rawExponent == 12);

//z is 0.0
frexp(z, calculatedExponent);
rawExponent = quantexp(z);
assert (calculatedExponent == 0  && rawExponent == -3);

Meta