Open the app
  1. Home
  2. Lessons
  3. GCSE & IGCSE Computer Science
  4. Two's complement signed integers

Two's complement signed integers

🎬 The doodle video for this lesson is coming soon. Subscribe on YouTube to see it first.

Unsigned binary can only store positive numbers. Two's complement lets 8 bits store negative numbers too.

Unsigned and signed

An unsigned 8-bit integer stores 0 to 255.
In two's complement, the most significant (left) bit is worth -128 instead of +128.
So 8 bits store -128 to +127. If the left bit is 1, the number is negative.

Making a negative number

To store -5:
1. Write +5 in binary: 00000101
2. Flip every bit: 11111010
3. Add 1: 11111011

Reading a negative number

Add the place values, remembering the left bit is -128.
10000001 = -128 + 1 = -127
Positive numbers look the same as unsigned: 01000001 = 65.
Worked example

Convert -20 to 8-bit two's complement.

  1. +20 = 00010100
  2. Flip: 11101011
  3. Add 1: 11101100

Answer: 11101100

Key idea

In 8-bit two's complement the left bit is worth -128, giving a range of -128 to +127. To make a negative: write the positive, flip the bits, add 1.

The interactive lesson includes the diagrams for this topic.

Check you have got it

Answer 6 quick questions with instant marking. If you get one wrong, GCSE-ready shows you why and gives you another go. It is free, and you do not need an account.