ilogb, ilogbf, ilogbl

Visual Studio 2015
 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at ilogb, ilogbf, ilogbl2.

Retrieves an integer that represents the unbiased base-2 exponent of the specified value.

int ilogb(  
   double x  
);  
  
int ilogb(  
   float x  
); //C++ only  
  
int ilogb(  
   long double x  
); //C++ only  
  
int ilogbf(  
   float x  
);  
  
int ilogbl(  
   long double x  
);  
  

Parameters

[in] x
The specified value.

If successful, return the base-2 exponent of x as a signed int value.

Otherwise, returns one of the following values, defined in <math.h>:

InputResult
±0FP_ILOGB0
±inf, ±nan, indefiniteFP_ILOGBNAN

Errors are reported as specified in _matherr.

Because C++ allows overloading, you can call overloads of ilogb that take and return float and long double types. In a C program, ilogb always takes and returns a double.

Calling this function is similar to calling the equivalent logb function, then casting the return value to int.

RoutineC headerC++ header
ilogb, ilogbf, ilogbl<math.h><cmath>

For additional compatibility information, see Compatibility.

Alphabetical Function Reference
frexp
logb, logbf, logbl, _logb, _logbf

Show: