In C++, the ilogb() function is defined in the <cmath> or <math.h> header file and is used to calculate the exponent part of a floating-point number. It returns the integral value of the logarithm of the given number using FLT_RADIX as the base.
The ilogb() function is equivalent to converting the result of logb() into an integer.
It has the following syntax.
x: It is the value whose exponent is to be calculated.
| Parameter | Return value |
|---|---|
| x=0 | -INT_MIN |
| x=NAN or +inf or _inf | INT_MAX |
Here, we are going to discuss several examples to demonstrate the List ilogb() Function Function.
This example demonstrates how the ilogb() function calculates the exponent part of a positive integer value.
Output:
Value of x is : 4 Exponent value of x is : 2
This example demonstrates how the ilogb() function calculates the exponent part of a floating-point number.
Output:
Value of x is : 10.5 Exponent value of x is : 3
This example demonstrates how the ilogb() function behaves when the input value is 0. In this case, the function returns INT_MIN.
Output:
Value of x is : 0
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India