Syntax
#include <math.h> double frexp(double x, int *expptr);Description
frexp breaks down the floating-point value x into a term m for the mantissa and another term n for the exponent, such that x=m*2n, and the absolute value of m is greater than or equal to 0.5 and less than 1.0 or equal to 0. frexp stores the integer exponent n at the location to which expptr points.
frexp returns the mantissa term m. If x is 0, frexp returns 0 for both the mantissa and exponent. The mantissa has the same sign as the argument x. The result of the frexp function cannot have a range error.
This example decomposes the floating-point value of x, 16.4, into its mantissa 0.5125, and its exponent 5. It stores the mantissa in y and the exponent in n.
#include <math.h>
int main(void)
{
double x,m;
int n;
x = 16.4;
m = frexp(x, &n);
printf("The mantissa is %lf and the exponent is %d\n", m, n);
return 0;
/****************************************************************************
The output should be:
The mantissa is 0.512500 and the exponent is 5
****************************************************************************/
}
Related Information