gdb ldexp
C ++ ldexp()函数 (C++ ldexp() function)
ldexp() function is a library function of cmath header, it is used to calculate the value from significand and exponent, it returns the multiplication of significand and 2 raised to the power of the exponent. It accepts two values (significand and exponent) and returns the result of significand x 2^exponent.
ldexp()函数是cmath标头的库函数,用于从有效数和指数计算值,它将有效数和2的乘积返回指数的幂。 它接受两个值(有效数和指数),并返回有效数x 2 ^指数的结果。
Syntax of ldexp() function:
ldexp()函数的语法:
C++11:
C ++ 11:
double ldexp (double significand, int exponent);
float ldexp (float significand, int exponent);
long double ldexp (long double significand, int exponent);
double ldexp (T significand, int exponent);
Parameter(s):
参数:
significand, exponent – represent the values to calculate the result from significand and exponent.
显着,指数 –表示从显着和指数计算结果的值。
Return value:
返回值:
It returns the multiplication of significand and 2 raised to the power of the exponent.
它将有效数和2的乘积返回指数幂。
Example:
例:
Input:
float s = 10.0f;
float y = 2.0f
Function call:
ldexp(x, y);
Output:
40 (10.0 * 2.0^2.0 = 10.0 * 4.0 = 40)
C ++代码演示ldexp()函数的示例 (C++ code to demonstrate the example of ldexp() function)
// C++ code to demonstrate the example of
// ldexp() function
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float s = 10.0f;
float e = 2.0f;
cout << "ldexp(" << s << "," << e << ") = " << ldexp(s, e) << endl;
s = 20.0f;
e = 0.0f;
cout << "ldexp(" << s << "," << e << ") = " << ldexp(s, e) << endl;
s = 36.2f;
e = 0.49f;
cout << "ldexp(" << s << "," << e << ") = " << ldexp(s, e) << endl;
return 0;
}
Output
输出量
ldexp(10,2) = 40
ldexp(20,0) = 20
ldexp(36.2,0.49) = 36.2
Reference: C++ ldexp() function
参考: C ++ ldexp()函数
翻译自: https://www.includehelp.com/cpp-tutorial/ldexp-function-with-example.aspx
gdb ldexp