Logical bitwise operations |
|
1. Use the standard boolean operators (&, |, and ^) to act upon two integer values. The short-circuit boolean operators (&& and ||) are not used for bitwise operations and will result in a compile error if attempted. |
|
2. Produce an integer result (of size int or larger) that is the logical AND, OR, or XOR of two operands. |
|
The rules for these operations are as follows: |
|
Operation
|
Rule
|
& |
If both corresponding operand bits are “on” the result bit is “on” |
| |
If either corresponding operand bit is “on” the result bit is “on” |
^ |
If corresponding operand bits are different the result bit is “on” |
|