Two's complement Cambridge IGCSE Computer Science (9–1) revision

Not started

Learn it

In plain words

Ordinary binary can only count upwards from zero. Two's complement is the usual way to store negative whole numbers as well.

The trick is simple: the leftmost bit is given a negative place value. In 8 bits it is worth −128, not +128. Everything else stays the same.

6 things to know

  1. The place values of an 8-bit two's complement number are −128, 64, 32, 16, 8, 4, 2, 1.
  2. If the leftmost bit is 1 the number is negative. If it is 0 the number is positive.
  3. The range of an 8-bit two's complement number is −128 to +127.
  4. To read one: add up the place values under the 1s, remembering that the first is −128.
  5. To write a negative number: write the positive number in 8-bit binary, flip every bit, then add 1.
  6. The same steps turn a negative number back into its positive: flip every bit and add 1.

Worked example

Write −35 as an 8-bit two's complement number.

  1. Write +35 in binary: 00100011.
  2. Flip every bit: 11011100.
  3. Add 1: 11011101.
  4. Check with the place values: −128 + 64 + 16 + 8 + 4 + 1 = −35.

Worked example

What is the denary value of the two's complement number 10110100?

  1. Place values under the 1s: −128, 32, 16 and 4.
  2. −128 + 32 + 16 + 4 = −76.

Tips and tricks

  • Always check a negative answer with the place values. If the leftmost bit is not 1, something has gone wrong.
  • Flip, then add 1. Adding 1 first and then flipping gives the wrong number.
5 questions, about 2 minutes.

It lands in your notebook with its questions as flashcards.

Two's complement: 5 questions and answers

These are the quiz’s questions. Do the quiz first, then come back here for the ones that got you.

  1. In 8-bit two's complement, what is the place value of the leftmost bit?
    • 128
    • −128 (the answer)
    • −127
    • −1

    It is the same size as in ordinary binary but negative.

  2. What is the 8-bit two's complement number 11111111 in denary?
    • 255
    • −127
    • −128
    • −1 (the answer)

    −128 + 127 = −1.

  3. What range of numbers can 8-bit two's complement store?
    • 0 to 255
    • −127 to 127
    • −128 to 127 (the answer)
    • −255 to 255

    The smallest is 10000000 = −128. The largest is 01111111 = 127.

  4. What is −6 in 8-bit two's complement?
    • 10000110
    • 11111001
    • 11111010 (the answer)
    • 01111010

    +6 is 00000110. Flip to get 11111001, then add 1.

  5. What is the 8-bit two's complement number 10000011 in denary?
    • 131
    • −3
    • −125 (the answer)
    • −131

    −128 + 2 + 1 = −125.

Still stuck on this one?Ask in the Papermunch Discord, or help someone else who is. Discord is for ages 13 and up.Join the server

Things you can type

Or go straight to

Or browse a shelf