frexp()

Extracts the mantissa and exponent from a floating point number's binary representation.

  #include <math.h>
  
  double frexp(double x, int* e);
  
  float frexpf(float x, int* e);
  
  long double frexpl(long double x, int* e);    
Parameter

x

The floating point value to extract from.

e

A pointer to an integer in which to store the exponent.

Remarks

A floating point number's binary representation follows this formula:

m 2 e

where m is the mantissa and e is the exponent, 0.5 < m < 1.0 and e is an integer value.

These functions return, when possible, the value of a floating-point number's exponent ine and returns the mantissa.

This facility may not be available on configurations of the EWL that run on platforms that do not have floating-point math capabilities.

Listing: Example of frexp() Usage

#include <math.h>

#include <stdio.h>

int main(void)

{

double m, value = 12.0;

int e;

m = frexp(value, &e);

printf("%f = %f * 2 to the power of %d.\n",value, m, e);

return 0;

}

Output:

12.000000 = 0.750000 * 2 to the power of 4.