Notes on the original code, complement

First, the original code

  A predetermined original code notation: indicates a signed value and a sign bit, the number of positive sign bit "0" indicates, with a negative sign bit "1", the value is expressed in binary form part.

  Such as:

     In eight coding, the original code values ​​from -2 ^ 7 + 1 + 2 ^ 7-1 

    x [original] = 01111111 x = 2 ^ 7-1 

    x [original] = 00000000 x = + 0

    x [original] = 10000000 x = -0

               x [original] = 11111111 x = -2 ^ 7 + 1

  Defect of the original code: 1, as with the positive and negative 0 0, represents the original code only the number 2 ^ 8-1.

              2, plus or minus the original code can not be directly calculated by adding the trouble inside the computer. Because the calculation should sign bit and magnitude bits separately.

          The 2 + (- 1) = 1, but it 00000010 + 10000001 = 10000011 true value -3

  Because the original code has such a defect, it is inside the computer, the more common method is to complement the numerical representation.

Second, complement

  Predetermined complement notation: complement positive numbers with the same original code, complement negative number as the original code except the sign bit inverted you, then add a

 

  Such as:

     In eight coding complement values ​​from -2 ^ 7 ^ 2 + 7-1 

          Provided true value x = 62, y = -62

    

 

 

 

 

    

Guess you like

Origin www.cnblogs.com/asdfknjhu/p/12079122.html
Recommended