C++ - How to check if not equal with the & operator

bit-manipulation, c++

Solution

You came close. `operator!` has a higher precedence than `operator&`, so you need parentheses:

if (!(flags & 0x00000001)) {
    //this is not a person
}

Problem

I am working on a project and we keep track of flags in a single byte. That byte can be set with a few options. For example: ``` 0x00000001 - Person 0x00000002 - Object 0x00000003 - Vehicle ``` Now, when it comes time to check these objects we can do this: if(flags&0x00000001) { // this is a person } The problem is, I want to know how to check and see if it is not a person. Forgive me if this is a simple answer but I have tried if !flags&0x00000001 and it does not check out. I have also tried comparing it to 0 and still, no luck.

Original source