AND operation (&), OR operation (|), XOR operation (^)
One: and operator (&)
Operation rules: 0 & 0 = 0; 0 & 1 = 0; 1 & 0 = 0; 1 & 1 = 1
Namely: false is false, both are 1 at the same time, the result is 1, otherwise it is 0
For example: 3 & 5
That is, 0000 0011
& 0000 0101
= 0000 0001, so 3 & 5 = 1
Two: OR operation (|)
Operation rules: 0 | 0 = 0; 0 | 1 = 1; 1 | 0 = 1; 1 | 1 = 1;
Namely: When true is true, as long as one is 1, its value is 1.
For example: 3 | 5
That is, 0000 0011
| 0000 0101
= 0000 0111, so 3 | 5 = 7.
Three: XOR operator (^)
Operation rules: 0 ^ 0 = 0; 0 ^ 1 = 1; 1 ^ 0 = 1; 1 ^ 1 = 0;
That is: the focus is on difference, if two bits are "exclusive" (different values), the result of this bit is 1, otherwise it is 0
For example: 3 ^ 5
That is, 0000 0011
^ 0000 0101
= 0000 0110, so 3 ^ 5 = 6