Two’s Complement

The Problem with Negative Numbers

In standard unsigned binary, adding a 1 anywhere only ever increases the value. There is no natural way to represent negative numbers. Computers solve this using two’s complement.


How Two’s Complement Works

The Most Significant Bit (MSB)

In two’s complement, the left-most bit (MSB) indicates the sign:

  • MSB = 0 → positive number
  • MSB = 1 → negative number

The MSB has a negative place value instead of a positive one.

Column Values in Two’s Complement (8-bit)

-1286432168421

The leftmost column is -128 (negative), all others remain positive.


Reading a Two’s Complement Number

Example: Read 11110110 as a signed integer

  • MSB is 1 → negative number
  • (-128) + 64 + 32 + 16 + 4 + 2 = -128 + 118 = -10

Example: Read 00001100 as a signed integer

  • MSB is 0 → positive number
  • 8 + 4 = +12

Converting a Positive Number to Its Negative (Two’s Complement Trick)

Method:

  1. Write the positive number in binary
  2. Starting from the right, copy all digits up to and including the first 1
  3. Flip (invert) all remaining digits to the left

Example: Convert +12 to -12

  1. +12 = 00001100
  2. From the right, copy up to the first 1: ...100 → keep 100
  3. Flip everything to the left of that: 00001 becomes 11110
  4. Result: 11110100

Verification: Add +12 and -12 → result should be 0:

  00001100  (+12)
+ 11110100  (-12)
──────────
 100000000  (overflow bit discarded → 00000000 = 0) ✓

8-bit Two’s Complement Range

Value
Most positive01111111 = +127
Zero00000000 = 0
Most negative10000000 = -128

Range: -128 to +127


Exam Questions

Q: How can you tell if a two’s complement number is negative?

If the left-most bit (MSB) is 1, the number is negative. If it is 0, the number is positive.

Q: Convert +12 to its two’s complement negative form.

Write 12 in binary: 00001100. Copy from the right up to and including the first 1: keep 100. Flip the remaining bits: 11110. Result: 11110100 (= -12).

Q: How do you verify a two’s complement conversion is correct?

Add the positive and negative versions together. If the result is zero (ignoring overflow), the conversion is correct.


Exam Tip

The trick (copy up to first 1, flip the rest) is much faster than the traditional “flip all bits then add 1” method, and gives the same result. Know either method.