1

mrahmedcomputing

KS3, GCSE, A-Level Computing Resources

Lesson 3. Binary Arithmetic


Lesson Objective

  1. Be able to add together up to three binary numbers.
  2. Apply binary shifts to multiply and divide numbers.

Lesson Notes

Addition - Column Method

Work right to left:

  1. Add the Units
  2. If Over 9 = 0 Carry Tens
  3. Add Tens

Here are examples of Base 10 numbers:

1 1
1 5 2 6
+ 1 7 + 1 9
3 2 4 5

Binary Addition - THE RULES!!

Work right to left and apply these simple rules:

  1. 0 + 0 = 0
  2. 0 + 1 = 1
  3. 1 + 0 = 1
  4. 1 + 1 = 0 Carry 1
  5. 1 + 1 + 1 = 1 Carry 1

Here are examples of two 8 bit numbers being added together:

1 1 1
0 0 0 0 1 1 1 0 14
+ 1 0 1 0 0 0 1 0 162
1 0 1 1 0 0 0 0 176

...

1 1 1 1
0 1 0 0 0 1 1 1 71
+ 0 1 1 0 0 0 0 1 79
1 0 1 0 1 0 0 0 150

Overflow Error

When and extra bit is created to represent a number.

Here is an example of an overflow error:

1 1 1 1 1
1 1 0 0 1 1 0 0 204
+ 1 0 0 1 1 1 0 1 157
1 0 1 1 0 1 0 0 1 361

Adding 3 Binary Numbers

Method 1.

Add the first two, then add the third to the result.

We will carry out the addition 1011 + 0111 + 101

We can can see the 1011 (11) + 0111 (7) + 101 (5) = 23

1 1 1 1
1 0 1 1 11
+ 0 1 1 1 7
1 0 0 1 0
+ 1 0 1 5
1 0 1 1 1 23

Method 2.


Logical Binary Shifts

Left Shift = Multiply. Each shift is the number multiplied by a power of 2

0 Shift 0 0 0 0 1 0 0 0 Original
1 Shift 0 0 0 1 0 0 0 0 *2
2 Shift 0 0 1 0 0 0 0 0 *4
3 Shift 0 1 0 0 0 0 0 0 *8

Right Shift = Divide. Each shift is the number division by a power of 2

0 Shift 0 0 0 1 0 0 0 0 Original
1 Shift 0 0 0 0 1 0 0 0 /2
2 Shift 0 0 0 0 0 1 0 0 /4
3 Shift 0 0 0 0 0 0 1 0 /8
3