I’m doing work with bitmasks these days, working on system maintenance on a web application I had nothing to do with building. One of the things it does is use Bitmasks to keep track of some customer data states. I’m not sure I like it, but I can’t deny that it’s a way to preserve staus in a very compact way.
Mask (computing) – Wikipedia, the free encyclopedia
The most common mask used, also known as a bitmask, extracts the status of certain bits in a binary string or number. For example, if we have the binary string 100111010 and we want to extract the status of the fifth bit counting along from the most significant bit, we would use a bitmask such as 000010000 and use the bitwise AND operator. Recalling that 1 AND 1 = 1, with 0 otherwise, we find the status of the fifth bit.