Docs

Topic 1 · Data representation

Binary addition, overflow, shifts, and negative numbers

Add 8-bit binary numbers, spot overflow, multiply and divide with logical shifts, and store negatives with two's complement.

Lesson 2 of 4Syllabus 1.1updated October 31, 2026

Adding binary

Binary addition works like column addition in denary, but you carry when a column reaches 2 instead of 10. There are only four rules:

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 1 = 0, carry 1
  • 1 + 1 + 1 = 1, carry 1
109 + 59 = 168
1286432168421
Carry1111111
10901101101
5900111011
16810101000
Work right to left. Write each carry above the next column so you do not lose it.

Overflow

An 8-bit register can hold at most 255. If an addition produces a bigger answer, a carry falls off the left end and there is no 9th bit to store it. This is an overflow error.

For example, 200 + 100 = 300, which needs 9 bits (100101100). The register keeps only the right-hand 8 bits, 00101100, which is 44. The answer is wrong.

Exam tip. When asked to identify overflow, say that the result is larger than the register can hold (more than 255 for 8 bits), so the final carry is lost.

Logical shifts

A logical shift moves every bit left or right by a number of places. Empty places are filled with 0s, and bits pushed off the end are lost.

Each shift left multiplies by 2. Each shift right divides by 2. Shifting left 3 places multiplies by 8.

Press the buttons to shift 00010110 (22). Shift left twice to get 88. Keep going and watch what happens when a 1 falls off.

Shift explorerInteractive
128
64
32
16
8
4
2
1
Denary 22
16 + 4 + 2 = 22
If a 1 is lost from the left, the result is wrong (overflow). If a 1 is lost from the right, the result is rounded down.

Two's complement

To store negative numbers, two's complement makes the left-most bit worth −128 instead of +128. Every other place stays positive. So a number starting with 1 is negative and a number starting with 0 is positive.

8-bit two's complement can store −128 to +127.

Two's complement explorerInteractive
-128
64
32
16
8
4
2
1
Denary -45
-128 + 64 + 16 + 2 + 1 = -45
11010011 = −128 + 64 + 16 + 2 + 1 = −45. Flip the left bit to see the sign change.

Making a number negative

To write a negative denary number in two's complement:

  1. 1
    Write the positive value
    45 → 00101101
  2. 2
    Flip every bit
    00101101 → 11010010
  3. 3
    Add 1
    11010010 + 1 → 11010011

Exam tip. To check your answer, add the place values with −128 for the left bit. You should get the number you started with.

Key terms

Overflow
When a result is too large for the number of bits available.
Logical shift
Moving all bits left or right, filling gaps with 0s.
Most significant bit
The left-most bit, with the largest place value.
Two's complement
A way to store negative integers where the most significant bit has a negative place value.

Check yourself

Add 01010101 and 00110011.Show answer

85 + 51 = 136 → 10001000. No overflow.

What is 00001101 after a logical left shift of 2 places? What has happened to the value?Show answer

00110100 = 52. It has been multiplied by 4 (13 × 4).

Convert −20 to 8-bit two's complement.Show answer

20 = 00010100, flip → 11101011, add 1 → 11101100.

What denary value is 10000001 in two's complement?Show answer

−128 + 1 = −127.