scalbln() function in C++ STL
Last Updated :
12 Jul, 2018
The scalbln() is a built-in function in C++ STL which takes two arguments and scales x by FLT_RADIX raised to the power n. The function returns the product of x and FLT_RADIX raised to the power n.
FLT_RADIX: It is the value of the radix (integer base) of the exponent representation.
Syntax:
scalbln (x, n)
Parameters: The function accepts two mandatory parameters which are described below:
- x– It specifies the value representing the significand. The data-type can be double, float or long-double.
- n– It specifies the exponent of FLT_RADIX. The parameter is of data-type long-int.
Return Type: The function returns the product of x and FLT_RADIX raised to the power n. The returned value is of the same data-type as of x.
Below programs illustrate the above function:
Program 1:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long int n = 0;
double x = 2.12, result;
result = scalbln(x, n);
cout << x << " * " << FLT_RADIX << "^"
<< n << " = " << result << endl;
return 0;
}
|
Output:
2.12 * 2^0 = 2.12
Program 2:
#include <bits/stdc++.h>
using namespace std;
int main()
{
long int n = 9999999;
double x = 19.8, result;
result = scalbln(x, n);
cout << x << " * " << FLT_RADIX << "^"
<< n << " = " << result << endl;
return 0;
}
|
Output:
19.8 * 2^9999999 = inf
Share your thoughts in the comments
Please Login to comment...