various people write:
I don't understand what you want to do with this. It (or something vaguely like it) will work to store flag values, but it wont let you do ordinary bit-vector math.
In particular, what happens if you want to match more than one flag variable at a time? You may want to do things logically like:
flags & (RCONF | RCHAOS) /* Example from NPP */
You can't do this if the high order bits and low order bits are dependent the way they would be in your example.
You just can't OR together array indexes to get valid array indexes. They are ordinal numbers, not orthogonal bits.
** tests then become (bitmap[FLAG/32] & (1<<(FLAG%32))), which a competent optimizing compiler should handle as efficiently as the current code.
In particular, what happens if you want to match more than one flag variable at a time? You may want to do things logically like:
flags & (RCONF | RCHAOS) /* Example from NPP */
You can't do this if the high order bits and low order bits are dependent the way they would be in your example.
You just can't OR together array indexes to get valid array indexes. They are ordinal numbers, not orthogonal bits.
Comment