1. In the case of a signed
The highest bit of the binary is the sign bit, and 1 indicates that the integer 1 represents a negative number
Positive source code Anti-code is the same
Negative number of the anti-code = its source symbol bit unchanged, the other bit to reverse
The complement of a negative number = its anti-code +1
0 's anti-code complement is 0.
Java has no unsigned number, and the number in Java is signed
In a computer operation, it's all in the form of a complement.
2. Bit arithmetic
Bitwise AND &: Two bits are all 1 and the result is 1
Bitwise OR |: Two bits have one of 1 and result is 1
Bitwise XOR: Two-bit one is 0, one is 1, and the result is 1
Bitwise de-0->1:1->0
3. Shift Operations
>> Arithmetic right shift: low overflow, sign bit invariant, and sign bit fill overflow high
<< arithmetic left shift: sign bit unchanged, low fill 0
>>> Logic right SHIFT, low overflow, high fill 0
-2 Original code: 10--010
Anti-code: 11--101
Complement: 11--110
Hanshunping Java note 20th BITS operation shift operation