gdb ldexp_ldexp()函数以及C ++中的示例

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值