&, ^, | Operators are called logical operators. Operators are used to connect computing objects with the C # syntax. Operators are called logical expressions. Logical operator "!" And "^" only act on the subsequent operands, so it is called The unary operator.
These three operators are used in expressions to generate a logical value of true or false.
The operations of logical operators on Expressions A and B are shown in the following table.
Logical operator running result
A |
B |
A & B |
A | B |
A ^ B
|
< |
> |
False |
False |
False |
False |
False
|
Left Shift |
Right Shift |
False |
True |
False |
True |
True
|
- |
- |
True |
False |
False |
True |
True
|
- |
- |
True |
True |
True |
True |
False
|
- |
- |
|The result is false only when both operands are false.&True is returned only when both operands are true.^True is returned only when only one operand is true.~Operators perform bitwise complement operations on the operands. The result is equivalent to reversing each bit.
<And> convert the number to be displaced to binary for parallel displacement.
Example:
Decimal: 3 | 2 = 3; 3 & 2 = 2; 3 ^ 2 = 1; 13> 1 = 6; 13 <1 = 26
Binary representation: 11 | 10 = 11; 11 & 10 = 2; 11 ^ 10 = 1, that is, the calculation result on the table by bit