该函数计算给定数字与FLT_RADX乘幂的乘积。
scalbn(x,n) = x * ( FLT_RADX)n
float scalbln(float x, long int n); double scalbln(double x, long int n); long double scalbln(long double x, long int n); double scalbln(integral x, long int n);
x :有效值。
n :指数的值。
它返回x和FLT_RADX乘积为n的乘积。
让我们看一下x的值为整数类型的简单示例。
#include <iostream> #include<math.h> #include<float.h> using namespace std; int main() { int x=3; long n=3L; std::cout << "Value of x is: " <<x<< std::endl; cout<<"3 * 2^3 = "<<scalbn(x,n); return 0; }
输出:
Value of x is: 3 3 * 2^3 = 24
让我们看一个简单的例子,当x的值为浮点型时
#include <iostream> #include<math.h> #include<float.h> using namespace std; int main() { float x=7.2; long n=2L; std::cout << "Value of x is : " <<x<< std::endl; cout<<"7.2 * 2^2 = "<<scalbln(x,n); return 0; }
输出:
Value of x is : 7.2 7.2 * 2^2 = 28.8
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)