Why do I need to use the source code, reverse code, complement code, and transfer code?

Source: Internet
Author: User
Tags modulus

The previous blog briefly introduced the computer Central Plains code, back code, complement and shift code representation (http://blog.csdn.net/xdd19910505/article/details/40424533), for the computer why it is not very clear, it seems to know such a thing, but I don't know why. It's like a person you don't know, he's not his friend, you don't know what he's ......

In fact, from the source code to the completion code is a progressive relationship, but also a process of gradual development in the wrong. That is to say, an error occurs when the original code operation and Subtraction is used. In order to solve the problem of reverse code operation, but the reverse code operation is not satisfactory, so there is a supplementary code for a better pursuit.



Appearance of modulus and population

Junior High School, senior high school, or elementary school let us know such a thing:

Rotate an object 90 degrees left and 270 degrees right without considering the number of circles;

270 + 90 = 360;

If you change the minute-hand to 20 minutes, and then 40 minutes, the effect is the same without considering the hour-hand;

20 + 40 = 60;

When the number 87, 25, and 75 are subtracted, the effect is the same without considering the number of hundred bits;

25 + 75 = 100;

.......

In short, there will be some premise not to consider, it can be seen that their relationship is complementary. The calculated values 360, 60, and 100 are the modulus in different situations. If you know the modulo, you can find the complement of a number.

Replace the original number with the complement number, and then use addition instead of subtraction. A carry is a modulo value.


Binary Mode:

The number of bits is involved in the operation. The modulo is the number of zeros added after 1.

For example, a two-digit binary number is used in an operation. The modulo is 100, that is, 2 ^ 2 = 4.

The 8-bit binary number is involved in the calculation, and the modulo is 100000000; that is, 2 ^ 8 = 256


Binary complement:

Calculates the complement of binary numbers to store them in the computer. Generally, the complement code is discussed based on the 8-bit binary number.

If a positive number is added during calculation, you do not need to obtain the complement code. Only subtraction (or adding a negative number) is required. The complement is defined according to this requirement: the positive number remains unchanged, and the negative number is calculated by the modulus minus the absolute value.

For example, if X =-126 and its complement code is 1000 0010, the calculation method is as follows:

1 0000 0000

-0111 1110

-------------

1000 0010

In fact, it is to store data and to make computing simple. Now that I can do this by completing the code, why do I still write the original code and the reverse code in the book? I personally think that they are of little use. They do not exist in computers. They are used to illustrate how binary complement is obtained in an image and only play a role in an intermediate computing process, if you want to write a data complement code at once, you need to turn several corners.

In fact, when I first got into tgb, the teacher talked about these things, but at that time I didn't listen to the teacher's words and wrote them again, that is why I have never heard of it in the soft exam stage. That day, Mr. Mi told us that he would write computation processes on his own. As for us, what qualifications should he be lazy to deal with such a problem? In fact, when you seem to write a simple computing process, but you do not have a simple step, you may not write it in a difficult place, so learn from the teacher! We should learn too much ......


I just want to deepen my impression on data representation. Maybe it's not clear, but it's my own understanding ...... In addition, we recommend a very good blog where the original code, anti-code, complement code, and transfer code expressions and their causes are all in it (it is much better than me, I also discovered it later (^_^ )). Http://www.cnblogs.com/zhangziqiu/archive/2011/03/30/ComputerCode.html


Why do I need to use the source code, reverse code, complement code, and transfer code?

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.