Home >>C Math Functions >C math frexp() function

C math frexp() function

C math frexp() function

C math double frexp() function is used to return the worth of the mantissa, and therefore the integer pointed to by exponent is that the exponent. The Value of the resultant x = mantissa * 2 ^ exponent.

Syntax:
double frexp(double x, int *exponent)

Parameter Values

Parameter Description
x It is the floating point value to be computed.
exponent It is the pointer to an int object where the value of the exponent is to be stored.
Here is an example of frexp() function:

#include <stdio.h>
#include <math.h>
int main () 
{
double x = 1024, fraction;
int e;
fraction = frexp(x, &e);
printf("x = %.2lf = %.2lf * 2^%d\n", x, fraction, e);
return(0);
}

Output:
x = 1024.00 = 0.50 * 2^11
Example-2

#include <stdio.h>
#include <math.h>
int main () 
{
double x = 525, fraction;
int e;
fraction = frexp(x, &e);
printf("x = %.2lf = %.2lf * 2^%d\n", x, fraction, e);
return(0);
}

Output:
x = 525.00 = 0.51 * 2^10

No Sidebar ads