📅  最后修改于: 2020-09-25 07:45:05             🧑  作者: Mango
该函数在
数学上
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 integral type
ldexp() 函数采用两个参数,并返回double
, float
或long double
类型的值。
ldexp() 函数返回表达式x * 2 exp的值 。
#include
#include
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;
}
运行该程序时,输出为:
ldexp(x, exp) = 52.224
#include
#include
using namespace std;
int main ()
{
double result;
int x = 25, exp = 5;
result = ldexp(x , exp);
cout << "ldexp(x, exp) = " << result << endl;
return 0;
}
运行该程序时,输出为:
ldexp(x, exp) = 800