assert(nLeadingBitsToCount(0xF0u, 3u) == 32 - 5); assert(nLeadingBitsToCount(0x700u, 3u) == 32 - 8); foreach(uint i; 1 .. 32) assert(nLeadingBitsToCount(uint.max, i) == i);
See Implementation