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