NOTE: Bitwise operators operate on the complement of integers, so the result of the operation is also complementary
& (with Operations)
Convert data to complement form, then treat 0 as False, 1 as true, bitwise AND operation, and finally convert the result to decimal to display
7 0000 0111
& 11 0000 1011
————————————
3 0000 0011
Note:
Even & any number = even
Positive & any number = positive
Odd & 1 = 1
Even & 1 = 0
| (or Arithmetic)
Convert data into complementary form, bitwise OR operation, and finally convert the result to decimal
7 0000 0111
| 11 0000 1011
————————————
15 0000 1111
Note:
Odd | Any number = odd
Negative numbers | Any number = negative
^ (XOR or operation)
Transform the data into a complement, bitwise XOR, and finally convert the result to decimal. Same bit false, different bit true.
7 0000 0111
^ 11 0000 1011
————————————
12 0000 1100
Note:
I ^ i = 0
J ^ 0 = j
I ^ j ^ j = I
~ (take inverse operation)
i = 5
~i =-6
5 Source: 0101
Complement of 5:0101
Inverse operation: 1010
Anti-code: 1001
Source: 1110----->-6
<<, >>, >>>
Https://www.cnblogs.com/chuijingjing/p/9405598.html
Java operators, bitwise operations