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乘以给定幂的幂的乘积。 它接受两个参数significand和exponent,并返回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语言 函数的参数传递示例