The two objects participating in the operation are calculated in binary bits.
Category translation address:Online Calculation Conversion
1: With operator (&)
Operation rules:
0&0=0;0&1=0;1&0=0;1&1=1
Right now:Two are 1 at the same time, and the result is 1, otherwise it is 0
For example: 3&5
Convert decimal 3 to binary 3:0000 0011
Convert decimal 5 to binary 5:0000 0101
----------------------------Result: 0000 0001 -> Convert to decimal: 1
That is: 3&5 = 1
Two: Or operation (|)
Operation rules:
0|0=0; 0|1=1; 1|0=1; 1|1=1;
That is: two objects participating in the operation,One is 1 and its value is 1.
For example: 3|5 is 00000011 | 0000 0101 = 00000111, so 3|5=7.
Three: XOR operator (^)
Operation rules: 0^0=0; 0^1=1; 1^0=1; 1^1=0;
That is: two objects participating in the operation, if the two bits are "extra"(different values), then the result of this bit is 1, otherwise it is 0.
For example: 3^5 = 0000 0011 | 0000 0101 =0000 0110, therefore, 3^5 = 6