Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

frexp, frexpf, frexpl - Split floating-point number into mantissa and exponent

&pagelevel(4)&pagelevel

Definition

#include <math.h>

double frexp(double value, int *e_p);
float frexpf(float value, int *e_p); (C11)
long double frexpl(long double value, int *e_p); (C11)

The functions split a floating-point number value into the mantissa x and the exponent n on thebasis of the formula:

value = x * 2n


|x|

n

is in the interval [0.5, 1.0[

is an integer


The result from these functions is the mantissa x and an integer value for the exponent n. The exponent is returned indirectly via a result parameter e_p.

frexp is the inverse function of ldexp.

Return val.

Mantissa x

a floating-point number of type double which satisfies the equation value = x * 2n and lies in the interval [0.5, 1.0[.

0

if value is equal to 0 (the exponent is also equal to 0 in this case).

Note

Note that the argument e_p must be a pointer!


Example

Normalized representation of the number 5 to base 2:

#include <stdio.h>
#include <math.h>
int main(void)
{
   double z;
   int exp;
   z = frexp((double)5, &exp);
   printf("5 = %g * 2 ** %d\n", z, exp);
   return 0;
}

See also

ldexp, modf