Note that MASK set in such a way that it has the lowest SHIFT bits set, where SHIFT is exactly the base-2 BITSPERWORD .
Therefore, (i & MASK) will select the least 5 bits of i , which will be the same as taking the remainder after dividing by 32 (just think about how taking the lower two digits of the decimal number gives you the remainder after dividing by 100, for example). This gives the number of bits in the word of interest to us.
1 << (i & MASK)) (this, by the way, is an expression, not an operator) now creates a value in which exactly the bit that is of interest to us is set. Combining this value into a memory word with |= will set the desired bit of the bit vector.
Henning makholm
source share