C++ ilogb()

Last Updated On Saturday 16th Apr 2022

The C++ ilogb() function returns the square root of sum of square of arguments passed. It is defined in <cmath> header file.


	ilogb(double x);


The ilogb() function takes a single argument.

Return value

Returns the integral part of the logarithm of |x|.

  • If the argument is , it returns FP_LOGB0.
  • If the argument is NaN, it returns FP_LOGBNAN.
  • If the argument is infinite, it returns INT_MAX.

ilogb() prototype [As of C++ 11 standard]

	int ilogb (double x);
int ilogb (float x);
int ilogb (long double x);
int ilogb (T x);

Example : C++ ilogb()

	#include <stdio.h>
#include <math.h>

int main () {
  double param;
  int result;
  param = 44.0;
  result = ilogb (param);
  printf ("ilogb(%f) = %d\n", param, result);
  return 0;


	ilogb(44.000000) = 5