Integral Bitwise Logical Operators
The available operators that deal with integral values—as usual defined for
ulong—include the following:
& | ^ ~
These, respectively, correspond to the bitwise AND, OR, XOR (exclusive OR), and complement operations. The following are a few examples:
int x = 5;int y = 3;int and = x & y; // 1int or = x | y; // 7int xor = x ^ y; // 6int compX = ~x; // -6
Figure 5.20 illustrates the operation of those operators (restricting myself to 4-bit representations to save space).