c语言 函数的参数传递示例_scalbn()函数以及C ++中的示例

c语言 函数的参数传递示例

C ++ scalbn()函数 (C++ scalbn() function)

scalbn() function is a library function of cmath header. It scales the significand using floating-point base exponent (int) i.e. it is used to calculate the product of the given significand and FLT_RADIX raised to the power of the given exponent. It accepts two parameters significand and exponent and returns the result of significand * FLT_RADIXexponent.

scalbn()函数cmath标头的库函数。 它使用浮点基指数(int)缩放有效位数,即,用于计算给定有效 位数FLT_RADIX乘以给定幂的幂的乘积。 它接受两个参数significandexponent,并返回significand * FLT_RADIX 指数的结果。

Syntax of scalbn() function:

scalbn()函数的语法:

C++11:

C ++ 11:

     double scalbn (double x     , int n);
      float scalbn (float x      , int n);
long double scalbn (long double x, int n);
     double scalbn (T x          , int n);

Parameter(s):

参数:

  • x, n – represent the value of significand and exponent.

    x,n –表示有效和指数的值。

Return value:

返回值:

It returns the product of the given significand and FLT_RADIX raised to the power of the given exponent.

它返回给定有效数与FLT_RADIX乘以给定指数幂的乘积。

Example:

例:

    Input:
    double x = 10;
    int n = 2;
    
    Function call:
    scalbn(x,n);
    
    Output:
    40

C ++代码演示scalbn()函数的示例 (C++ code to demonstrate the example of scalbn() function)

// C++ code to demonstrate the example of
// scalbn() function

#include <iostream>
#include <cmath>
using namespace std;

// main() section
int main()
{
    double x;
    int n;

    x = 10;
    n = 2;
    cout << "scalbn(" << x << "," << n << "): " << scalbn(x, n);
    cout << endl;

    x = 5.3;
    n = 2;
    cout << "scalbn(" << x << "," << n << "): " << scalbn(x, n);
    cout << endl;

    x = 15.46;
    n = 12.56;
    cout << "scalbn(" << x << "," << n << "): " << scalbn(x, n);
    cout << endl;

    x = -10.2;
    n = 2;
    cout << "scalbn(" << x << "," << n << "): " << scalbn(x, n);
    cout << endl;

    return 0;
}

Output

输出量

scalbn(10,2): 40
scalbn(5.3,2): 21.2
scalbn(15.46,12): 63324.2
scalbn(-10.2,2): -40.8

Reference: C++ scalbn() function

参考: C ++ scalbn()函数

翻译自: https://www.includehelp.com/cpp-tutorial/scalbn-function-with-example.aspx

c语言 函数的参数传递示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值