In a computer, the number of symbols is represented by a complement.
1. Original code
The first digit of the original code is the symbol bit, and the other digits represent the value. For example, 8-bit binary:
[+ 1] original = 0000 0001
[-1] original = 1000 0001
2. Supplemental code
The positive complement is itself. The negative complement is based on the original code, and the symbol bit remains unchanged. The rest are reversed by + 1.
[+ 1] Complement = 0000 0001
[-1] Complement = 1111 1111
The rules for converting the complement code to the original code remain the symbol bit unchanged, and the rest will be reversed to + 1.
3. Shift
When the number of symbols is shifted, they are all shifted in the form of a complement code:
Shift right: discard the rightmost digit, and fill the leftmost sign bit.
Left shift: discard the leftmost part and add 0 to the rightmost part.
Binary, complement, and shift