cbit-manipulationcompound-operator

C - Logical Compound Operators


Is the compound operator '&=' logical or bitwise AND ?

In other words, is a &= b the same as:


Solution

  • a &= b is using the bitwise AND operator. Think of the += operation:

    a += 5;
    

    is the same as:

    a = a + 5;
    

    It's just a combination of two operations: & and =.