safeOp.ilogb

Get the base 2 logarithm of abs(num), rounded down to the nearest integer.

safeOp.ilogb(0) will raise IntFlag.undef.

template safeOp(IntFlagPolicy policy)
@safe
int
ilogb
(
N
)
(
const N num
)

Examples

import checkedint.sticky : safeOp; // use IntFlagPolicy.sticky

assert(safeOp.ilogb( 20) == 4);
assert(safeOp.ilogb(-20) == 4);

safeOp.ilogb(0);
assert(IntFlags.local.clear() == IntFlag.undef);

Meta