The logical (Boolean) operator is used to calculate the expression of the result of the boolean type. The result of the operation is boolean type. The calculation result is as follows:
Operator |
Operation |
Example |
Result |
& |
And (and) |
False & True |
False |
| |
Or (OR) |
False | true |
True |
^ |
XOR (exclusive or) |
False ^ true |
True |
! |
Not (not) |
! False |
True |
&& |
And (Short Circuit) |
False & True |
False |
| |
Or (Short Circuit) |
False | true |
True |
The following is a simple explanation of some problems:
1. "^" refers to the logic of the calculated operand "exclusive or". That is to say, the result is true only when only one operand is true.
2. the difference between "&" and "&" is that if the former is used for join, expressions on both sides of "&" are involved in calculation under any circumstances. If the latter connection is used, if the left side of "&" is false, the expression on the right side is not calculated.
3. the difference between "|" and "|" is that "|" indicates that any Boolean expression on both sides is true, and true is returned for the combination. For "| ", similar to the second. If the left side is true, true is returned. If the left side is falsh, the right side is displayed. If the right side is true, true is returned. Otherwise, falsh is returned.