Menu

Unsigned Binary to Negative Binary Conversion

Converting Negative Denary to Two's Complement

Two's complement is the method computers use to store negative whole numbers in binary. To turn a negative denary number into its 8-bit two's complement pattern, start from the positive version of the number and follow three steps: write the positive value in 8 bits, flip every bit, then add 1.

Carrying out the three steps

  1. Write the positive value as 8 bits. Pad with leading zeros so the pattern is exactly 8 bits long.
  2. Flip every bit. Every 0 becomes a 1 and every 1 becomes a 0. Missing even one bit spoils the answer.
  3. Add 1 to the flipped pattern. Do the addition in binary, carrying where two 1s meet, and keep the answer to 8 bits.

The flip on its own gives a pattern that is one less than the value you need: the flipped 9 is 11110110, which is -10, not -9, so the add-one step must come after the flip, never before. A quick check on your answer: a negative number always starts with a 1 in the leftmost bit, while a positive number starts with 0. You only use these steps for negative values, because a positive number's pattern is already correct as it stands.

Worked example for -9

Step8-bit pattern
Positive 9 in binary00001001
Flip every bit11110110
Add 111110111

So -9 is stored as 11110111. A second run-through: positive 20 is 00010100, which flips to 11101011, and adding 1 gives 11101100 for -20.

Three rows of eight bit boxes show -9: positive 9 is 00001001, flipping every bit gives 11110110, and adding 1 gives 11110111. The leftmost bit is marked as the sign bit.

Practise this

Edexcel GCSE Computer Science · Unsigned Binary to Negative Binary Conversion