C examples for math.h:ldexp
function
<cmath> <ctgmath> <math.h>
Returns the result of multiplying x (the significand) by 2 raised to the power of exp (the exponent).
lexpr(x,exp) = x * 2^ exp
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);
Parameter | Description |
---|---|
x | Floating point value representing the significand. |
exp | Value of the exponent. |
The function returns: x * 2^ exp.
#include <stdio.h> #include <math.h> int main ()/*from ww w . j av a 2 s. c om*/ { double param = 0.95; int n = 4; double result = ldexp (param , n); printf ("%f * 2^%d = %f\n", param, n, result); return 0; }