The bitwise operators and logical operators include the AND operator &
, exclusive OR operator ^
, and inclusive OR operator |
. These operators have different
precedence, with &
having the highest precedence and |
the lowest precedence.
Each of these operators is syntactically left-associative (each groups left-to-right).
Each operator is commutative if the operand expressions have no side effects.
Each operator is associative.
AndExpression:
EqualityExpression
AndExpression&
EqualityExpression ExclusiveOrExpression:
AndExpression
ExclusiveOrExpression^
AndExpression InclusiveOrExpression:
ExclusiveOrExpression
InclusiveOrExpression|
ExclusiveOrExpression
The bitwise and logical operators may be used to compare two operands of numeric type or two operands of type boolean
. All other cases result in a compile-time error.