Computer Science Essentials, Unit 6, Lesson 2 of 5

Binary addition and shifts

GCSE Computer Science, Data representation, 20 minutes

Sign in

Add binary numbers with carries, recognise overflow, and use left and right shifts to multiply and divide.

What you will learn

  • Add two or three binary numbers
  • Explain overflow
  • Carry out left and right shifts and say their effect

Adding in binary

Add from the right, column by column, just as in denary.

SumWriteCarry
0 + 000
0 + 110
1 + 101
1 + 1 + 111

The rules for one column: 0 + 0 = 0, 0 + 1 = 1, 1 + 1 = 10 (write 0, carry 1) and 1 + 1 + 1 = 11 (write 1, carry 1). A worked example:

  1. Add 0011 0110 (54) and 0001 1011 (27).
  2. Right column: 0 + 1 = 1. Next: 1 + 1 = 10, write 0 carry 1. Next: 1 + 0 + carry 1 = 10, write 0 carry 1.
  3. Next: 0 + 1 + carry 1 = 10, write 0 carry 1. Next: 1 + 1 + carry 1 = 11, write 1 carry 1.
  4. Next: 1 + 0 + carry 1 = 10, write 0 carry 1. Next: 0 + 0 + carry 1 = 1. Left column: 0 + 0 = 0.
  5. Answer: 0101 0001, which is 81 = 54 + 27.

To add three numbers, add the first two, then add the third to that answer.

Always check in denary: convert both numbers, add, and convert back.

A register is a small store inside the processor that holds a fixed number of bits. Overflow happens when the result needs more bits than there are. Adding two 8-bit numbers whose total is over 255 produces a ninth bit; in an 8-bit register it is lost and the stored answer is wrong.

The rest of this lesson and its 7 practice questions are locked.

In this lesson

  1. Adding in binary
  2. Binary shifts
  3. Try it: Add two numbers

7 practice questions, marked as you go; about 20 minutes in all.

Key terms

Register, Overflow, Left shift, Right shift

In this unit: Data representation

Binary, denary and hexadecimal, binary addition and shifts, two's complement, and how characters, images and sound are stored and compressed.

All of Data representation