safeOp.bsr

core.bitop.bsr without the undefined behaviour. safeOp.bsr(0) will raise IntFlag.undef.

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

Examples

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

assert(safeOp.bsr( 20) ==  4);
assert(safeOp.bsr(-20) == 31);

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

Meta