In this C++ tutorial, you will learn how to compute the value of x scaled by FLT_RADIX to the power exp using scalbln() function of cmath, with syntax and examples.

## C++ scalbln()

C++ scalbln(x, exp) computes the value of x scaled by FLT_RADIX to the power exp.

`scalbln(x, exp) = x * FLT_RADIX^exp`

## Syntax

The syntax of C++ scalbln() is

`scalbln(x, exp)`

where

Returns

The return value depends on the type of value passed for parameter x.

The return value of scalbln(x, exp) is

• double if x is double or integral type value.
• float if x is float.
• long double if x is long double.

The synopsis of scalbln() function is

```double scalbln(double x, long int exp);
float scalbln(float x, long int exp);
long double scalbln(long double x, long int exp);
double scalbln(Type1 x, long int exp); // for integral types```

scalbln() is a function of cmath library. Include cmath library at the start of program, if using scalbln() function.

## Example

In this example, we read two values from user into variables x and exp, and compute result of scalbln(x, exp).

C++ Program

```#include <iostream>
#include<cmath>
using namespace std;

int main() {
double x;
long int exp;
cout << "Enter x   : ";
cin >> x;
cout << "Enter exp : ";
cin >> exp;

double result = scalbln(x, exp);
cout << "scalbln(" << x << ") : " << result << endl;
}```

Output

```Enter x   : 5
Enter exp : 3
scalbln(5) : 40
Program ended with exit code: 0```
```Enter x   : 8
Enter exp : 1
scalbln(8) : 16
Program ended with exit code: 0```

If `x` is NaN, scalbn() returns NaN.

```Enter x   : nan
Enter exp : 3
scalbln(nan) : nan
Program ended with exit code: 0```

## Conclusion

In this C++ Tutorial, we learned the syntax of C++ scalbln(), and how to use this function, with the help of examples.