Create your own
Lesson illustration

Binary Addition, Logical Shifts, and Overflow

Hello. In the previous lesson, you converted between denary, binary, and hexadecimal, using binary place values such as . Now you will use those same place values to calculate with binary.

This lesson covers binary addition, logical left and right shifts, and overflow when a result cannot fit in the fixed number of bits available. At O Level, questions commonly use eight-bit unsigned binary values, so we will use that format throughout.


Binary addition: the same principle, a different base

Addition works in any place-value system. In denary, when a column totals or more, we write a digit and carry into the next column. In binary, each column can contain only or , so carrying happens much sooner.

There are four rules to memorise:

Binary calculationResult writtenCarry
none
or none

The last two rules make sense when checked in denary:

So write in the current column and carry into the next column to the left.

Similarly:

So write and carry .

Always add from right to left, beginning at the least significant bit (LSB).

Worked example: addition within eight bits

Calculate:

Write the values in aligned columns:

The answer is:

A denary check confirms this:

The important point is that carries are not special “binary tricks.” They follow naturally from the fact that binary is base .

Binary addition and binary shift - Fundamentals of data representation - AQA - GCSE Computer Science Revision - AQA - BBC Bitesize

Read BBC Bitesize's “Binary addition and binary shift” to consolidate the four addition rules, see worked column additions, and connect a final carry to overflow.

In the section “Binary addition and binary shift”, begin at the introduction to binary addition. Read through the examples of two-number and three-number addition. Then continue to the subsection “Overflow”, ending with the eight-bit overflow example. Focus on where each carry is placed and why a carry beyond the leftmost available column matters.


Fixed width and overflow in addition

A binary answer only overflows when there is a limit on the number of bits that can be stored.

For an unsigned eight-bit value:

and the greatest possible value is:

In general, an unsigned -bit value can represent values from to:

If an addition produces a ninth bit, it cannot be stored in an eight-bit location. That lost carry is called overflow.

Worked example: overflow

Add:

Mathematically, the full answer is:

The full answer needs nine bits:

But if only eight bits are available, the leftmost cannot be stored. The stored result is therefore:

This is overflow. It does not mean that ; it means that the hardware lacked enough bits to store the correct result.

For unsigned addition, use either of these equivalent checks:

  • A carry leaves the most significant bit (MSB).
  • The denary total is greater than for eight-bit values.

Keep the specified bit width in your final answer. Writing only when the question requires an eight-bit result misses the practical consequence: overflow.

Exam language: “Overflow occurs because the result requires nine bits, but only eight bits are available” is a precise explanation.


Logical binary shifts

A logical shift moves every bit a stated number of positions and fills newly empty positions with .

For this lesson, numbers are unsigned: they represent only zero or positive values. Later, signed values use two’s complement and require a different interpretation.

The two directions are:

ShiftWhat happensNumerical effect, if no important bit is lost
Logical left shiftBits move towards the MSB; zeros enter at the rightMultiply by for each place
Logical right shiftBits move towards the LSB; zeros enter at the leftDivide by for each place, discarding any remainder

The multiplication and division effects follow directly from place value. Moving a from the column to the column doubles its contribution. Moving it from to halves it.

A fixed-width logical left shift: each bit moves one place toward the most significant bit, the bit leaving the left side is discarded, and a \(0\) is inserted at the least significant bit.

Logical left shift

Consider the eight-bit value:

A logical left shift by one place gives:

The new value is:

Thus:

A left shift by two places multiplies by , provided the result still fits:

More generally, shifting left by places multiplies by:

However, this rule is valid only when no bit is shifted out of the left side.

Overflow in a left shift

Now shift this eight-bit number left once:

A was removed from the MSB, so overflow has occurred.

Mathematically, doubling gives:

But is outside the unsigned eight-bit range of to . The computer retains only the eight bits that fit:

The stored answer is therefore not the true doubled value.

For a left shift of places, inspect the leftmost original bits:

  • If they are all , no overflow occurs.
  • If any one of them is , that bit will be lost, so overflow occurs.

Logical right shift

In a logical right shift, every bit moves towards the LSB. A is inserted at the MSB end.

Start with:

Shift right once:

So the value has been divided by :

A two-place right shift divides by . For example:

Right shifts can discard a remainder

Unlike left shifting, a right shift can lose information from the right side. Consider:

Shift right once:

The last has been discarded:

Yet:

Binary integers cannot store the fractional part in this format, so the result becomes . In effect, a logical right shift performs whole-number division by a power of , discarding any remainder.

Do not call this overflow. In the O Level context, overflow refers to a being lost from the MSB during a left shift, or to a calculation needing more bits than are available.

1.2.4 Binary Shifts - Revise OCR GCSE Computer Science

Watch “1.2.4 Binary Shifts” from Revise Computer Science for a visual explanation of why moving bits changes their place values and why right shifts can lose precision.

Watch left shifts to see one-place and two-place shifts become multiplication by 2 and 4. Then watch right shifts, focusing on the example where discarded bits make the result an integer approximation rather than an exact division.


A reliable exam method

For any question involving binary addition or shifts, use this sequence.

  1. Identify the width. If the question says eight bits, keep exactly eight result bits.
  2. For addition, align the LSBs and work right to left, recording carries carefully.
  3. For a left shift, move bits left, insert zeros at the right, and check whether a left the MSB.
  4. For a right shift, move bits right, insert zeros at the left, and note whether a was discarded from the LSB end.
  5. Check in denary when time permits. This is particularly useful for detecting an unexpected overflow.

Here is a compact summary.

OperationEight-bit exampleResultKey issue
Addition without overflowAll carries fit
Addition with overflow storedCarry beyond eighth bit
Left shift by oneMultiplies by
Left shift with overflowA leaves the MSB
Right shift by oneLSB is lost; remainder discarded

Key takeaways

Binary addition uses four rules:

Add from right to left and carry exactly as in denary, but at a total of rather than .

For unsigned eight-bit values, the available range is:

An addition overflows when it produces a carry beyond the eighth bit. A logical left shift overflows when a is shifted out from the MSB.

Logical shifts insert zeros:

  • a left shift by places multiplies by , unless overflow occurs;
  • a right shift by places divides by , discarding any fractional remainder.

The next Computer Science lesson extends binary representation to signed integers using two’s complement, where the leftmost bit has a new role.

Can't find a good explanation? Sign up and we'll make it for you

Sign up