ldexp -- Multiply by a Power of Two

Format

#include <math.h>
double ldexp(double x, int exp);

Language Level: ANSI, POSIX, XPG4
ldexp calculates the value of x * (2exp).

Return Value
ldexp returns the value of x*(2exp). If an overflow results, the function returns +HUGE_VAL for a positive result or -HUGE_VAL for a negative result, and sets errno to ERANGE. If an underflow results (when the exponent is negative), the function returns 0.0, and sets errno to ERANGE.

Example
This example computes y as 1.5 times 2 to the fifth power (1.5*25):

#include <math.h>
#include <stdio.h>
int main(void)
{
   double x,y;
   int p;
   x = 1.5;
   p = 5;
   y = ldexp(x, p);
   printf("%lf times 2 to the power of %d is %lf\n", x, p, y);
   return 0;
   /***********************************************************
      The output should be:
      1.500000 times 2 to the power of 5 is 48.000000
   ***********************************************************/
}


exp -- Calculate Exponential Function
frexp -- Separate Floating-Point Value
modf -- Separate Floating-Point Value
<math.h>