To test if a bit is set:
if ((mask & flag) != 0) {
// bit is set
} else {
// bit is not set
}
To set a bit:
mask |= flag;
To clear a bit:
mask &= ~flag;
To toggle a bit:
mask ^= flag;
To test if a bit is set:
if ((mask & flag) != 0) {
// bit is set
} else {
// bit is not set
}
To set a bit:
mask |= flag;
To clear a bit:
mask &= ~flag;
To toggle a bit:
mask ^= flag;