C++ Math scalbln
The function computes the product of a given number and FLT_RADX raised to the power of exponent.
Suppose a number is 'x' and exponent is 'n':
Example
scalbn(x,n) = x * ( FLT_RADX)n
Syntax
Example
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);
Parameter
x : The value of the significand.
n : The value of the exponent.
Return value
It returns the product of x and FLT_RADX raised to the power n.
Example 1
Let's see the simple example when the value of x is an integer type.
Example
#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;
}
Output:
Output
Value of x is: 3
3 * 2^3 = 24
Example 2
Let's see the simple example when the value of x is a float type
Example
#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;
}
Output:
Output
Value of x is : 7.2
7.2 * 2^2 = 28.8