 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
ilogb() function in C++ STL
In this article, we will be discussing the working, syntax, and examples of ilogb() function in C++.
What is ilogb()?
ilogb() function is an inbuilt function in C++ STL, which is defined in <cmath< header file. ilogb() is used to find the integer part of the logarithm value. ilogb() means integer binary logarithm.
This function returns an integral part of the logarithm of |x| using the FLT_RADIX as the base for logarithm.
Syntax
int ilogb(double x);
Parameters
The function accepts the following parameter(s) −
- x− This is the value whose logarithm we have to find. 
Return value
This function returns the integral logarithm of |x|, using the value of FLT_RADIX as the base value. This function also throws an exception according to the parameter’s value.
If the parameter value is −
- NaN − Then the function return FP_LOGBNAN. 
- Infinite − Then the function return INT_MAX. 
- 0 − Then the function returns FP_LOGB0 
Input
ilogb(2);
Output
1
Example
#include <cfloat> #include <cmath> #include >iostream> using namespace std; int main(){    int output, var = 2;    output = ilogb(var);    cout << "The value of ilogb(" << var << ") is: " << output << endl;    return 0; }  Output
If we run the above code it will generate the following output −
The value of ilogb(2) is: 1
Example
#include <cfloat> #include <cmath> #include <iostream> #include <iostream> using namespace std; int main(){    int output, var = 10.23;    output = ilogb(var);    cout << "The value of ilogb(" << var << ") is: " << output<< endl;    return 0; } Output
If we run the above code it will generate the following output −
The value of ilogb(10) is: 3
