Using Bitwise operators on flags

If you want all bits in the test mask to match:

if((value & mask) == mask) {...}

If you want any single bit in the test mask to match:

if((value & mask) != 0) {...}

The difference is most apparent when you are testing a value for multiple things.

To test for exclusion:

if ((value & mask) == 0) { }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)