frexp | function |
double frexp ( double x, int * exp ); float frexp ( float x, int * exp ); long double frexp ( long double x, int * exp ); |
<cmath> |
Get significand and exponent
Breaks the floating point number x into its binary significand (a floating point value between 0.5 and 1.0) and an integral exponent for 2, such that:
x = significand * 2 exponent
The exponent is stored in the location pointed by exp, and the significand is the value returned by the function.
If x is zero, both parts (significand and exponent) are zero.
Parameters
- x
- Floating point value to be computed.
- exp
- Pointer to an int object where the value of the exponent is to be stored.
Return Value
The binary significand of x.This value is the floating point value in the interval [0.5,1] which, once multiplied by 2 raised to the power of *exp*, yields x.
Portability
In C, only the double version of this function exists with this name.Example
/* frexp example */ #include <stdio.h> #include <math.h> int main () { double param, result; int n; param = 15.2; result = frexp (param , &n); printf ("%lf * 2^%d = %f\n", result, n, param); return 0; } |
Output:
0.950000 * 2^4 = 15.200000 |
See also
ldexp | Generate number from significand and exponent (function) |
log | Compute natural logarithm (function) |
pow | Raise to power (function) |