Two's Complement

Almost all computers represent negative integers using two's complement.

Obtaining the two' complement representation of a negative number is easy.

  • Start with representation as positive integer.

  • Flip the bits (one's complement).

  • Add one.

    For example:

     1210 = 00001100 
         -> 11110011 one's complement
                  +1
    -1210 = 11110100 two's complement
    
     4210 = 00101010 
         -> 11010101 one's complement
                  +1
    -4210 = 11010110 two's complement
    

    Index