GOOC - Game Oriented Object C

GOOC - Game Oriented Object C

Next: Address-of Operator, Previous: Bitwise Shift Operators, Up: Expressions and Operators
[Contents]

7.6. Bitwise Logical Operators

7.6. Bitwise Logical Operators

Provided are operators for performing bitwise conjunction, inclusive disjunction, exclusive disjunction, and negation (complement).

Biwise conjunction examines each bit in its two operands, and when two corresponding bits are both 1, the resulting bit is 1. All other resulting bits are 0. Here is an example of how this works, using binary numbers: 11001001 & 10011011 = 10001001

Bitwise inclusive disjunction examines each bit in its two operands, and when two corresponding bits are both 0, the resulting bit is 0. All other resulting bits are 1. 11001001 | 10011011 = 11011011

Bitwise exclusive disjunction examines each bit in its two operands, and when two corresponding bits are different, the resulting bit is 1. All other resulting bits are 0. 11001001 ^ 10011011 = 01010010

Bitwise negation reverses each bit in its operand: ~11001001 = 00110110