Quote:
Originally Posted by KevinH
If type & mask == mask should work for whatever the bitmask is assuming it is truly a mask (ie. that all bits set in the mask exist (are set) in the type value since & is a bitwise operator
[...]
What am I missing?
|
You're only testing whether all bits are set or not. For a 1-bit mask this is ok, as it can only encode the values 0 and 1.
With a two-bit mask the encoded values are 0, 1, 2 and 3 (but 3 means more than 2 and the real value is stored in a separate byte). The current code doesn't decode these values.
Ciao,
Steffen