The OpenD Programming Language

ilogb

Extracts the exponent of x as a signed integral value.

If x is not a special value, the result is the same as cast(int) logb(x).

Special Values
xilogb(x)Range error?
0FP_ILOGB0yes
±∞int.maxno
NaNFP_ILOGBNANno
  1. int ilogb(T x)
  2. int ilogb(T x)
    @safe pure nothrow @nogc
    int
    ilogb
    (
    T
    )
    (
    const T x
    )
  3. int ilogb(T x)

Examples

assert(ilogb(1) == 0);
assert(ilogb(3) == 1);
assert(ilogb(3.0) == 1);
assert(ilogb(100_000_000) == 26);

assert(ilogb(0) == FP_ILOGB0);
assert(ilogb(0.0) == FP_ILOGB0);
assert(ilogb(double.nan) == FP_ILOGBNAN);
assert(ilogb(double.infinity) == int.max);

Meta