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

Math Ilogb Function

BLUF: Mastering Math Ilogb 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 Ilogb Function

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

C++ Math ilogb

The function retrieves the exponent component of a specified number, which is essentially the whole number portion of the logarithm of x.

ilogb function is equivalent to (int)logb

Syntax

Example

int ilogb(float x);
int ilogb(double x);
int ilogb(long double x);
int ilogb(integral x);

Parameter

x : It represents the numerical value for which the exponent needs to be determined.

Return value

Parameter Return value
x=0 -INT_MIN
x=NAN or +inf or _inf INT_MAX

Example

Let's see the simple example

Example

#include <iostream>
#include<math.h>
#include<float.h>
using namespace std;
int main()
{
 int x=4;
 std::cout << "Value of x is : " <<x<< std::endl;
 cout<<"Exponent value of x is : "<<ilogb(x);
 return 0;
}

Output:

Output

Value of x is : 4
Exponent value of x is : 2

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