Math Scalbln Function - C++ Programming Tutorial
C++ Course / Math Functions / Math Scalbln Function

Math Scalbln Function

BLUF: Mastering Math Scalbln Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Math Scalbln Function

C++ is renowned for its efficiency. Learn how Math Scalbln Function enables low-level control and high-performance computing in the tutorial below.

C++ Math scalbln

The function calculates the result of multiplying a specified number by FLT_RADX raised to the exponent power.

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 calculates the result of multiplying x by FLT_RADX to the nth power.

Example 1

Let's explore a basic scenario where the variable x holds an integer data 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 explore a straightforward scenario where the variable x is of the float data 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

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience