The original code, anti-code and complement

   Note: number stored in binary form with the calculator, which stores the number of machines in the form of numbers called. The highest digit is the sign bit, 0 for positive, 1 for negative.

     Since the first bit is the sign bit, the value is not necessarily equal to the number of machines in the form of a real value, so, the number of machines with a sign bit corresponding to the true value is called the true value. Example: 0000 + 000 = 0001 + 1 = 0001; 1000 0001 = -0000001 = -1.

 

  Original code: The first one is the sign bit, the remaining bits represent a value, therefore, is a positive number of the original code itself, a first negative original code is 1, it indicates negative.

     Example: +1 Hara: 0000 0001;

        -1 original: 1000 0001.

     Since the first bit is the sign bit, 8-bit binary values ​​are: [11111111, 01111111] = [- 127, 127].

 

  Anti-Code: positive anti-code of its own, the original code inverted negative, based on the sign bit unchanged, the other bit is inverted becomes 0,0 to 1 [1].

     Example: + 1 = [0000 0001] Original = [0000 0001] trans

        -1 = [1000 0001] Original = [1111 1110] trans 

  

  Complement: complement number is positive in itself, it is negative in the anti-complement code based on the sign bit change, the last one [+1 binary: 1 to 1 + 0; 1 + 1 becomes 0, the first bit + 1】

     Example: + 1 = [0000 0001] Original = [0000 0001] trans = [0000 0001] Complement

        -1 = [1000 0001] Original = [1111 1110] trans = [1111 1111] Complement

        -2 = [1000 0010] Original = [11111101] trans = [1111 1110] Complement

Guess you like

Origin www.cnblogs.com/20183711PYD/p/11571765.html