ldexp - C math.h

C examples for math.h:ldexp

Type

function

From

<cmath>
<ctgmath>
<math.h>

Description

Returns the result of multiplying x (the significand) by 2 raised to the power of exp (the exponent).

lexpr(x,exp) = x * 2^ exp

Prototype

long double ldexpl(long double x, int exp);
long double ldexp (long double x, int exp);
     double ldexp (double x, int exp);
      float ldexpf(float x , int exp);
     double ldexp (T x     , int exp); 

Parameters

Parameter Description
x Floating point value representing the significand.
exp Value of the exponent.

Return Value

The function returns: x * 2^ exp.

Example

Demo Code


#include <stdio.h>
#include <math.h>

int main ()/*from w ww  .ja va2  s .c  o  m*/
{
  double param = 0.95;
  int n = 4;
  double result = ldexp (param , n);
  printf ("%f * 2^%d = %f\n", param, n, result);
  return 0;
}

Related Tutorials