Negative numbers: Two's complement

Another method of representing signed numbers is two's complement. Most computers use this method to represent negative numbers. This method can be more effective when performing mathematical operations like adding and subtracting.

With two's complement, the bit at the far left of the bit pattern - the most significant bit or MSB - is used to indicate positive or negative and the remaining bits are used to store the actual size of the number. Positive numbers always start with a 0.

Four-bit, positive, two's complement numbers would be 0000 = 0, 0001 = 1, up to 0111 = 7. The smallest positive number is the smallest binary value.

Negative numbers always start with a 1. The smallest negative number is the largest binary value. 1111 is -1, 1110 is -2, 1101 is -3, etc down to 1000 which represents -8.

An explanation of how to use two's complement to create negative binary numbers

Using two's complement for negative numbers

  1. Find the positive binary value for the negative number you want to represent.
  2. Add a 0 to the front of the number, to indicate that it is positive.
  3. Invert or find the complement of each bit in the number.
  4. Add 1 to this number.

Examples

Find -1 using two's complement numbers

  1. 1 = 001
  2. Adding 0 to the front becomes 0001
  3. 'Inverted' becomes 1110
  4. Add 1 = 1111 (-8 + 4 + 2 + 1 = -1)

Find -4 using two's complement numbers

  1. 4 = 100
  2. Adding 0 to the front becomes 0100
  3. 'Inverted' becomes 1011
  4. Add 1 = 1100 (-8 + 4 = -4)

This table shows the two's complement set for 4-bit numbers.

Denary4-bit binary
-81000
-71001
-61010
-51011
-41100
-31101
-21110
-11111
00000
10001
20010
30011
40100
50101
60110
70111