Home >>C Math Functions >C math ldexp() function
C math ldexp() function is used to return the value of given input x multiplied by 2 raised to the given input power of exponent.
Syntax:double ldexp(double x, int exponent)
Parameter | Description |
---|---|
x | It is the floating point value representing the significand. |
exponent | It is the value of the exponent. |
#include <stdio.h>
#include <math.h>
int main ()
{
double x, ret;
int n;
x = 0.65;
n = 3;
ret = ldexp(x ,n);
printf("%f * 2^%d = %f\n", x, n, ret);
return(0);
}
#include <stdio.h>
#include <math.h>
int main ()
{
double x, ret;
int n;
x = 2.5;
n = 11;
ret = ldexp(x ,n);
printf("%f * 2^%d = %f\n", x, n, ret);
return(0);
}