
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library function - frexp()
Description
The C library function double frexp(double x, int *exponent) return value is the mantissa, and the integer pointed to by exponent is the exponent. The resultant value is x = mantissa * 2 ^ exponent.
Declaration
Following is the declaration for frexp() function.
double frexp(double x, int *exponent)
Parameters
x − This is the floating point value to be computed.
exponent − This is the pointer to an int object where the value of the exponent is to be stored.
Return Value
This function returns the normalized fraction. If the argument x is not zero, the normalized fraction is x times a power of two, and its absolute value is always in the range 1/2 (inclusive) to 1 (exclusive). If x is zero, then the normalized fraction is zero and zero is stored in exp.
Example
The following example shows the usage 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); }
Let us compile and run the above program to produce the following result −
x = 1024.00 = 0.50 * 2^11