C++ Math ilogb()

Last Updated : 20 May 2026

Math ilogb() Function

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.

Syntax

It has the following syntax.

Parameters

x: It is the value whose exponent is to be calculated.

Return value

ParameterReturn value
x=0-INT_MIN
x=NAN or +inf or _infINT_MAX

Examples of the List ilogb() Function

Here, we are going to discuss several examples to demonstrate the List ilogb() Function Function.

Example 1: Calculate the Exponent Part of a Positive Integer Using ilogb()

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

Example 2: Calculate the Exponent Part of a Floating-Point Value Using ilogb()

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

Example 3: Calculate ilogb() for Zero

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