safeOp.bsr

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

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

Examples

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

Meta