English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++The ldexp(x, exp) function in the product uses two parameters: x and exp, and returns x and2product, whose product is the power of exp, that is, x * 2 exp.
The function is in<cmath>defined in the header file.
Mathematically
ldexp(x, exp) = x * 2exp
double ldexp(double x, int exp); float ldexp(float x, int exp); long double ldexp(long double x, int exp); double ldexp(T x, int exp); //for integer
The ldexp() function has two parameters and returns a value of type double, float, or long double.
x -representing a floating-point value with significant digits.
exp -exponent value.
ldexp() function returns the expression x * 2 expvalue.
#include <iostream> #include <cmath> using namespace std; int main () { double x = 13.056, result; int exp = 2; result = ldexp(x, exp); cout << "ldexp(x, exp) = " << result << endl; return 0; }
When running the program, the output is:
ldexp(x, exp) = 52.224
#include <iostream> #include <cmath> using namespace std; int main () { double result; int x = 25, exp = 5; result = ldexp(x, exp); cout << "ldexp(x, exp) = " << result << endl; return 0; }
When running the program, the output is:
ldexp(x, exp) = 800