Math Ilogb Function

C++ Math ilogb

The function returns the exponent part of a given number i.e integral part of logx.

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 is the value whose exponent is to be calculated.

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: