Information Technology Reference
In-Depth Information
Logical Operators
The bitwise logical operators are often used to set the bit patterns for parameters to
methods. The operators are listed in Table 8-12.
These operators, except for bitwise negation, are binary and left-associative. The bitwise
negation operator is unary.
Table 8-12. The Logical Operators
Operator
Name
Description
&
Bitwise AND
Produces the bitwise AND of the two operands. The resulting bit
is 1 only if both operand bits are 1.
|
Bitwise OR
Produces the bitwise OR of the two operands. The resulting bit is
1 if either operand bit is 1.
^
Bitwise XOR
Produces the bitwise XOR of the two operands. The resulting bit is
1 only if one, but not both, operand bits are 1.
~
Bitwise negation
Each bit in the operand is switched to its opposite. This produces
the 1's complement of the operand.
The binary bitwise operators compare the corresponding bits at each position in each of
their two operands, and set the bit in the return value according to the logical operation.
Search WWH ::




Custom Search