How do I check, if bitmask contains bit?
well
if (8 & bitmask == 8 ) {
}
will check if the bitmask contains 8.
more complex
int mask = 8 | 12345;
if (mask & bitmask == mask) {
//true if, and only if, bitmask contains 8 | 12345
}
if (mask & bitmask != 0) {
//true if bitmask contains 8 or 12345 or (8 | 12345)
}
may be interested by enum and more particularly FlagsAttibute.
I'm pretty sure (A & B)==B
where A
is the bitmask and B
is whatever you want to check should do.
Example:
if((18358536 & 8) == 8)
{
// mask contains 8
}