The original code, reverse code, complement code, and transfer code are actually very simple.

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.