15.22.1 Integer Bitwise Operators &, ^, and |
When both operands of an operator &, ^, or | are of a type that is convertible
(§5.1.8) to a primitive integral type, binary numeric promotion is first performed
on the operands (§5.6.2). The type of the bitwise operator expression is the promoted
type of the operands.
For &, the result value is the bitwise AND of the operand values.
For ^, the result value is the bitwise exclusive OR of the operand values.
For |, the result value is the bitwise inclusive OR of the operand values.
For example, the result of the expression 0xff00 & 0xf0f0 is 0xf000. The
result of 0xff00 ^ 0xf0f0 is 0x0ff0.The result of 0xff00 | 0xf0f0 is 0xfff0.
15.22.2 Boolean Logical Operators &, ^, and |
When both operands of a &, ^, or | operator are of type boolean or Boolean, then
the type of the bitwise operator expression is boolean. In all cases, the operands
are subject to unboxing conversion (§5.1.8) as necessary.
For &, the result value is true if both operand values are true; otherwise, the
result is false.
For ^, the result value is true if the operand values are different; otherwise,
the result is false.
For |, the result value is false if both operand values are false; otherwise,
the result is true.