English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C Library Function double frexp(double x, int *exponent) Split the floating-point number x into the mantissa and exponent. The return value is the mantissa, and the exponent is stored in exponent . The obtained value is x = mantissa * 2 ^ exponent.
Below is the declaration of the frexp() function.
double frexp(double x, int *exponent)
x -- The floating-point value to be calculated.
exponent -- A pointer to an object that stores the value of the exponent.
The function returns the normalized decimal. If the parameter x is not zero, the normalized decimal is the square of x, and its absolute value range is from 1/2Contains) to 1If x is zero, the normalized decimal is zero, and zero is stored in exp.
The following example demonstrates the usage of the frexp() function.
#include <stdio.h> #include <math.h> int main () { double x = 2048, 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 produce the following result:
x = 2048.00 = 0.50 * 2^12