Important: The information in this document is obsolete and should not be used for new development.
frexp
You can use thefrexp
function to find out the values of a floating-point number's fraction field and exponent field.
double_t frexp (double_t x, int *exponent);
x
- Any floating-point number.
exponent
- A pointer to an integer in which the value of the exponent can be returned.
DESCRIPTION
Thefrexp
function splits its first argument into a fraction part and a base 2 exponent part. This is an ANSI standard C library function.such that
or
such that and
The return value of
frexp
is the value of the fraction field of the argumentx
. The exponent field ofx
is stored in the address pointed to by theexponent
argument.For finite nonzero inputs,
frexp
returns either 0.0 or a value whose magnitude is between 0.5 and 1.0.The
ldexp
andscalb
functions perform the inverse operation (compute ).EXCEPTIONS
If x is finite and nonzero, the result of is exact.SPECIAL CASES
Table 10-13 shows the results when the input argument to thefrexp
function is a zero, a NaN, or an Infinity.
Special cases for the frexp
functionOperation Result Exceptions raised +0 (n = 0) None (n = 0) None NaN (n is undefined) None[34] + (n is undefined) None (n is undefined) None EXAMPLES
z = frexp(2E300, n); /* z 0.746611 and n = 998. In other words, 2 10300 0.746611 2998. */
[34] If the NaN is a signaling NaN, the invalid exception is raised.