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)
int
ilogb
@safe
(
N
)
(
const N num
)
if (
isFixedPoint!N
)

Examples

1 import checkedint.sticky : safeOp; // use IntFlagPolicy.sticky
2 
3 assert(safeOp.ilogb( 20) == 4);
4 assert(safeOp.ilogb(-20) == 4);
5 
6 safeOp.ilogb(0);
7 assert(IntFlags.local.clear() == IntFlag.undef);

Meta