ldexp()

Constructs a floating point value from a mantissa and exponent.

  #include <math.h>
  
  double ldexp(double x, int exp);
  
  float ldexpf(float x, int exp);
  
  long double ldexpl(long double x, int exp);    
Parameter

x

A mantissa value.

exp

A exponent value.

Remarks

The ldexp() functions compute x * 2 exp. These functions can be used to construct a floating point value from the values returned by the frexp() functions.

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 ldexp() Usage

#include <math.h>

#include <stdio.h>

int main(void)

{

double value, x = 0.75;

int e = 4;

value = ldexp(x, e);

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

return 0;

}

Output:

0.750000 * 2 to the power of 4 is 12.000000.