BitFlag
State Variables
MASK_ODD_BITS
uint256 private constant MASK_ODD_BITS = 0x5555555555555555555555555555555555555555555555555555555555555555;
MASK_EVEN_PAIRS
uint256 private constant MASK_EVEN_PAIRS = 0x3333333333333333333333333333333333333333333333333333333333333333;
MASK_NIBBLES
uint256 private constant MASK_NIBBLES = 0x0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F;
BYTE_MULTIPLIER
uint256 private constant BYTE_MULTIPLIER = 0x0101010101010101010101010101010101010101010101010101010101010101;
Functions
popCount
Counts the number of set bits in a bit flag using parallel counting. This algorithm is based on the "Counting bits set, in parallel" technique from: https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
function popCount(uint256 bitFlag) internal pure returns (uint256);
Parameters
Name | Type | Description |
---|---|---|
bitFlag | uint256 | The bit flag to count the number of set bits. |
Returns
Name | Type | Description |
---|---|---|
<none> | uint256 | count The number of set bits in the bit flag. |