English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
C ++The scalbln(x, n) function in the scalbln() takes two parameters: x and n, and raises x to the nth power of the FLT_RADIX base.
In short, simply put, the scalbln() function returns the product of x and the nth power of the FLT_RADIX base.
FLT_RADIX is the value of the base (integer base) in exponential notation.
The function is in<cmath>Defined in the header file. In addition, you need to use the <cfloat> header file to use FLT_RADIX.
scalbln(x, n) = x * FLT_RADIXn
double scalbln(double x, long int n); float scalbln(float x, long int n); long double scalbln(long double x, long int n); double scalbln(T x, long int n); //Here, T is an integer type
It is similar toscalbn() functionare the same, but it uses long int as the second parameter.
scalbln() has two parameters:
x -The value representing the number of significant digits
n-The exponent value of FLT_RADIX
The return value of scalbln() is x * FLT_RADIXn
If the result is too large to be represented by the return type's value, the function will return HUGE_VAL with the correct sign.
#include <iostream> #include <cmath> #include <cfloat> using namespace std; int main()} { long int n = 133; double x = 3.056, result; result = scalbln(x, n); cout << x << " * cout << x << " << FLT_RADIX << "^" << n << " = " << result << endl; return 0; }
The output when running the program is:
3.056 * 2^133 = 3.32769e+40