Recently, when preparing for the soft exam and reviewing the computer composition principles, I can see the definition of the original code, reverse code, complement code, and transfer code in the book as follows (N indicates the machine font length.):
Original code:
Anti-code:
Complement:
Code transfer:
After reading these definitions, my head instantly doubles! No matter whether you remember this abnormal formula, I cannot remember it! Fortunately, I used to understand them. Otherwise, I am afraid I will give up the idea of taking the soft exam.
In fact, there is no need to make it so troublesome. They can be clearly described in one or two sentences.
Original code:
If the machine word length is N, the original code of a number uses a n-bit binary number, where the highest bit is the symbol bit: the positive number is 1, and the negative number is 0. The remainder n-1 bits represent the absolute value of the estimate. Example: x = + 101011, [x] original = 00101011 x =-101011, [x] original = 10101011 If the number of digits is not enough, use 0 to complete. PS: the original, reverse, and complement codes of positive numbers are the same.
Anti-code:
Knowing what the source code is, the anti-code is even more like Zhang Fei's bean sprout-a piece of cake. Once you know the source code, you only need to be able to distinguish between 0 and 1 to easily find the reverse code. Why? Because the anticode is based on the original code, the symbol bit remains unchanged and the other bit is reversed by bit (that is, the value of 0 is changed to 0.
Example: x =-101011, [x] original = 10101011, [x] inverse = 11010100
Complement:
The complement code is also very simple, that is, add 1 based on the normal addition operation on the basis of the anticode.
Example: x =-101011, [x] original = 10101011, [x] inverse = 11010100, [x] Complement = 11010101
Code transfer:
It is the easiest to move the code. No matter whether it is positive or negative, you only need to reverse the signed bits of the complement code.
Example: x =-101011, [x] original = 10101011, [x] inverse = 11010100, [x] Complement = 11010101, [x] shift = 01010101
The above content is only suitable for beginners. Do not spray it. If you say something wrong, please point it out. Thank you!