C library functions - frexp ()
description
C library functionsdouble frexp (double x, int * exponent) into the floating point number x mantissa and exponent.The return value is the mantissa, and theexponent of the index is stored.The resultant value isx = mantissa * 2 ^ exponent.
statement
Here is frexp () function's declaration.
double frexp(double x, int *exponent)
parameter
- x - a floating point value to be calculated.
- exponent - a pointer to an object, the object stores the value of the exponent.
return value
This function returns the normalized decimal. If the parameter x is not zero, the decimal is normalized quadratic x, and its absolute value range from 1/2 (inclusive) to 1 (not included). If x is zero, the normalized decimal is zero and zero is stored in exp in.
Examples
The following example demonstrates frexp () function is used.
#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); }
Let's compile and run the above program, which will result in the following:
x = 1024.00 = 0.50 * 2^11