Binary storage

The original binary code, anti-code complement

First, the original code

     Is a computer in the digital binary fixed-point representation, the original code, regardless of their positive and negative are in line with the first bit 0 is 1 for positive or negative.

   For example: 10 for binary: 0,000,000,000,000,000 0,000,000,000,001,010.

       -10 binary is: 1,000,000,000,000,000 0,000,000,000,001,010.

Second, anti-code

  1, for a positive number is inverted so that he himself does not change.  

  2, is inverted for negative numbers on the original code itself is a little different, his basic rules in addition to his sign bit, the original code into negative numbers 0, 1 becomes 0, is obtained by the negative anti-code.

    10 is inverted such as: 00000000 00000000 0,000,000,000,001,010.

    -10 anti-code is: 1,111,111,111,111,111 1,111,111,111,110,101.

Third, complement

  1, for a positive number for his original code, complement, anti-code are the same so positive number will not change.

  2, for a negative complement for his principles: in its last plus 1, then get is its complement.

    -12 original code: 10001100 MSB unchanged, the remaining bit inversion: 11110011, was added to give a complement: 11110100.

Summary: Positive anti-code, the original code, complement the same. In the presence of complement negative numbers are in the computer, the principle remains unchanged for the next symbol, the negative of the original code becomes 0 becomes 0, 1, resulting that the inverted negative, then the 1 plus its result is negative complement

 

 

 

Guess you like

Origin www.cnblogs.com/guziteng1/p/11530072.html