Little experience on the original code, anti-code complement

Before watching this article, please analogy to abandon the idea of ​​the clock, personally I feel that understanding the methods really do not need, but also easy to confuse yourself.

Here come 

 

In the real world, figures are expressed in source, such as natural binary positive and negative natural binary 4 4 only difference is the highest bit of the sign bit. As the computer world is not a subtraction, so all the numbers need to show up in the form of complement, including positive and negative numbers, and then adding the complement on it, the result is still a complement operation, we need to change back to the source, in the real world can see at a glance numbers it represents.


Source of positive (i.e. the most significant bit is the sign bit 0) of trans and complement its own.

Negative source (i.e., the most significant bit is a sign bit, the remaining bits, and no positive difference) of trans and complement sign bit to ensure constant value plus 1 bit is inverted.


Negative 128 (source) code is eight counter 1, the complement of the same source as the inverted value of bit 7 is 1 and also when adding 1 has overflowed, but can not sign bit, the sign bit is still 1, while a value of 0 bits has overflowed. (,,,,,,,,, 0000 0000 1000 0000 0 -128) (-127 1111 1111)
 

Calculation complement computer, and do not take nothing natural binary calculation, the sign bit also participate in operations, the results returned by the positive or negative source which can, of course, the source itself or a positive number.

Published 29 original articles · won praise 3 · Views 3401

Guess you like

Origin blog.csdn.net/qq_41601836/article/details/103743916