What is scalbnf in C/C++?

We use the scalbnf() function to compute the product of a given number with FLT_RADIX raised to the given power.

FLT_RADIX is a constant which serves as the base of the exponent.

Usually, in all computers, this value is 2.

Library For C++

#include<cmath>

Library For C

#include<math.h>

We have to use #include<cfloat> library for C++ and #include<float.h> library for C to access FLT_RADIX.

Syntax

float scalbnf(float num, int n)

Parameters

num: Accepts input value of a float type. This is the coefficient or mantissa value.

n: Exponent value or the number to which FLT_RADIX is raised.

Return value

The return value is the product of the given number, num, with FLT_RADIX raised to power n.

Formula

widget

Code

#include <iostream>
#include<cmath>
#include <cfloat>
using namespace std;
int main()
{
float num = 5.2;
int n = 4;
float result = 0;
cout << num << " * " << FLT_RADIX << "^" << n << " = " << scalbnf(num , n) << endl;
}

Free Resources

HowDev By Educative. Copyright ©2025 Educative, Inc. All rights reserved