C <math.h> - FP_ILOGB0, FP_ILOGBNAN
The C <math.h> ilogb() function returns the integer part of the logarithm of |x| (mod of argument), using FLT_RADIX as base for the logarithm. On most platforms, FLT_RADIX is 2.
In special cases, macros - FP_ILOGB0 and FP_ILOGBNAN are returned by this function:
Macros | Description |
---|---|
FP_ILOGB0 | Returned when x is zero. |
FP_ILOGBNAN | Returned when x is NaN. |
Example:
Lets consider example below to understand macros - FP_ILOGB0 and FP_ILOGBNAN.
#include <stdio.h> #include <math.h> int main (){ //returned value when argument is zero printf("ilogb(0) = %d\n", ilogb(0)); printf("FP_ILOGB0 = %d\n", FP_ILOGB0); printf("\n"); //returned value when argument is NaN printf("ilogb(sqrt(-1)) = %d\n", ilogb(sqrt(-1))); printf("FP_ILOGBNAN = %d\n", FP_ILOGBNAN); return 0; }
The output of the above code will be:
ilogb(0) = -2147483648 FP_ILOGB0 = -2147483648 ilogb(sqrt(-1)) = -2147483648 FP_ILOGBNAN = -2147483648
❮ C <math.h> Library