How A Computer Works

1 Learning Objectives

By the end of the lesson…

  • All Should know that there are different number systems, decimal, binary, amongst others.
  • Most Should know that digital data is represented by two discrete values (on/off, yes/no, 1/0)
  • Most Should be able to convert the numbers 0 to 7 from decimal to binary
  • Some Could be able to convert a wide range of numbers from decimal to binary and vice versa.
  • Some Could be able to perform simple binary addition.

2 Binary

Learn It

  • If you were asked to count to nine, then you'd probably do something along the lines of the following. (Click to reset)
  • But what happens when you want to go higher than nine?
  • You suddenly run out of new numbers and have to reuse digits you've already used.
  • The counting system we use is called base 10, often called denary. This means we have 10 unique numbers (0 up to 9). When we start counting and reach the number 9 and want to continue, we use a preceding 1 (to indicate that we have a single unit of 'tens'), and then start counting from 0 again.
  • You've probably not given much thought to why we count in 10's but a simple explanation has been provided by Georges Ifrah in his book The Universal History of Numbers.

Traces of the anthropomorphic origin of counting systems can be found in many languages. In the Ali language (Central Africa), for example, "five" and "ten" are respectively moro and mbouna: moro is actually the word for "hand" and mbouna is a contraction of moro ("five") and bouna, meaning "two" (thus "ten"="two hands").

It is therefore very probable that the Indo-European, Semitic and Mongolian words for the first ten numbers derive from expressions related to finger-counting. But this is an unverifiable hypothesis, since the original meanings of the names of the numbers have been lost.

  • What this basically means is that we're not 100% sure why we count in 10s, but it's probably because we have ten fingers.

Research It

  • Not all cultures count using base 10.
  • Conduct some research online to see if you can find out about other numbering systems used by other cultures.

Learn It

  • Computers don't use base 10
  • Computers chips are basically constructed from transistors that are organised to act as switches.
  • You'll learn more about transistors in the next lesson, but for now think of each transistor as a switch. I can be ON or OFF (in much the same way as a light-switch can).
  • This means that computers use a base 2 numbering system, called binary. ON is represented by the number 1 and OFF is represented by the number 0.

Learn It

  • Counting in binary looks like this
  • You can compare binary and denary numbers below.

Try It

  • You can convert between binary and denary or denary and binary fairly easily.
  • The exercises below will help you learn how to do this.
  • To convert from binary - denary
    1. Click on the cards, so that they flip over, until the number shown below the cards matches the binary number you are trying to convert. (ignoring preceding 0's)
    2. Count the number of spots that are displayed in total.
    3. This is your denary number.
  • To convert from denary - binary
    1. Click on the cards to flip them until you have the correct number of spots showing, equal to the denary number you are trying to convert.
    2. Read off the binary number (ignoring preceding 0's) that are displayed below.
  • Try converting 1001 from binary into denary, you should get the number 9
  • Try converting 19 from denary into binary, you should get the number 10011

Learn It

  • Have you figured out the general method yet?
  • Notice how many spots are on each card - 1,2,4,8,16….
  • Let's see if we can use this pattern to convert larger binary numbers.
  • Let's try the number 10100110
  • The number consists of 8 bits (We use the term bit to describe each unit)
  • Let's write out the number
1   0   1   0   0   1   1   0
  • Now above the binary number, write the number of spots that would have appeared on each card. (Start on the right, with the number 1 and then double it each time.
128 64  32  16  8   4   2   1
1   0   1   0   0   1   1   0
  • Now multiply each bit by the denary number above it.
128 64  32  16  8   4   2   1
1   0   1   0   0   1   1   0 X
-----------------------------
128 0   32  0   0   4   2   0
  • Now calculate the sum of these numbers
128 + 32 + 4 + 2 = 166

Try It

  • Have a go yourself with the following binary numbers - 1001011, 1110110, 11111111

Badge It - Silver

  • To get you Silver Badge convert the following numbers from binary to denary

One

128 64 32 16 8 4 2 1 Total
0 1 0 0 0 1 1 0 Ans here

Two

128 64 32 16 8 4 2 1 Total
1 0 0 1 1 0 0 0 Ans here

Three

128 64 32 16 8 4 2 1 Total
0 0 1 1 1 1 1 1 Ans here

Four

128 64 32 16 8 4 2 1 Total
0 1 1 0 1 0 1 1 Ans here

Five

128 64 32 16 8 4 2 1 Total
1 0 0 1 0 1 0 1 Ans here

Six

0 1 1 1 1 0 0 1 Ans here

Learn It

  • Let's try converting from denary to binary.
  • We'll use the number 200.
  • We'll start by writing out the spots that would have been on the cards.
128 64  32  16  8   4   2   1
  • Now we need to do a little mental arithmetic. Starting from the left, we see that the number 128 can go into 200. 200/128 = 1 with a remainder of 72.
  • Let's write a 1 below the 128
128 64  32  16  8   4   2   1
1
  • We're left with a 72 remainder.
  • We now move to the next number - 64. 64 can go into 72. 72/64 = 1 remainder 8
  • Let's write a 1 below the 64.
128 64  32  16  8   4   2   1
1   1
  • We're left with an 8 remainder.
  • We now move to the next number - 32. 32 can not go into 8.
  • So we write a 0 below the number 32
128 64  32  16  8   4   2   1
1   1   0
  • We still have the remainder 8. 16 can not go into 8
128 64  32  16  8   4   2   1
1   1   0   0
  • We still have the remainder 8. 8 can go into 8 with a remainder of 0.
128 64  32  16  8   4   2   1
1   1   0   0   1
  • As all we have left is 0, we can add trailing 0's to our number.
128 64  32  16  8   4   2   1
1   1   0   0   1   0   0   0
  • So our binary number is 11001000

Try It

  • Have a go yourself with the following practise denary numbers -

Example A

Denary 128 64 32 16 8 4 2 1
47                

Example B

Denary 128 64 32 16 8 4 2 1
128                

Example C

Denary 128 64 32 16 8 4 2 1
201                

Badge It - Gold

  • To get your Gold Badge convert the following numbers from denary to binary

One

Denary 128 64 32 16 8 4 2 1
97                

Two

Denary 128 64 32 16 8 4 2 1
134                

Three

Denary 128 64 32 16 8 4 2 1
230                

Four

  • 21

Five

  • 49

Six

  • 17

Seven

  • 183

Eight

  • 200

3 Adding in Binary

Badge It - Platinum

  • Adding binary numbers is pretty much the same as adding denary numbers.
    • 0 + 0 = 0
    • 0 + 1 = 1
    • 1 + 0 = 1
    • 1 + 1 = 10 (or 0 and carry the 1)
    • 1 + 1 + 1 = 11 (or 1 and carry the 1)
  • Try performing the following additions
    • 100 + 11
    • 100 + 100
    • 100 + 1100
    • 11001 + 10101

Validate