在本文中,我们将讨论scalbn()
C ++ STL中函数的工作,语法和示例。
scalbn()
啊scalbn()函数是C ++ STL中的内置函数,该函数在<cmath>头文件中定义。scalbn()
函数用于使用浮点基指数显着缩放。
有效数字是由有效数字组成的浮点数的一部分,具体取决于对指数的解释,有效数字可以是整数或分数。
该函数计算num和FLT_RADIX与幂n的乘积,其中FLT_RADIX是所有浮点数据类型的基础,而num是有效值。和n指数值
double scalbn( double num, int n ); float scalbn( float num, int n ); long double scalbn( long double num, int n );
该函数接受以下参数-
num-它是有效值。
n-它是指数值。
如果成功,此函数返回num * FLT_RADIX ^ n,否则返回math_errhandling错误。
scalbn(5, 7);
输出结果
640
#include <bits/stdc++.h> using namespace std; int main(){ int a = 7; int b = 5; int hold; hold = scalbn(b, a); cout <<"Equation is: "<< b << " * " << FLT_RADIX << "^" << a << " = "<<hold<< endl; return 0; }
输出结果
Equation is: 5 * 2^7 = 640
#include <bits/stdc++.h> using namespace std; int main(){ float a = 2.3; float b = 7.8; float hold; hold = scalbn(b, a); cout <<"Equation is: "<< b << " * " << FLT_RADIX << "^" << a << " = "<<hold<< endl; return 0; }
输出结果
Equation is: 7.8 * 2^2.3 = 31.2