nTrailingBitsToCount

T
nTrailingBitsToCount
(
T
)
(
in T value
,
in T popcnt
)
if (
__traits(isUnsigned, T)
)

Examples

assert(nTrailingBitsToCount(0xF0u, 3u) == 7);
assert(nTrailingBitsToCount(0xE00u, 3u) == 12);

foreach(uint i; 1 .. 32)
    assert(nTrailingBitsToCount(uint.max, i) == i);

Meta