CS05 : It's all about the base


Computers don't count in denary like we do. They are made a switches and don't have any fingers. They count in Base 2 or Binary. Part of being a computer scientists is being able to count in different number bases than the one that we normally count in.

We are learning ...
  • About different number bases
So that we can ...
  • Describe the format of number systems
    - The concept of a number base
    - Writing numbers to include their base, nB
  • Describe and use the denary number system
  • Describe and use the binary number system
  • Discuss the concept of binary coding
  • Represent unsigned denary numbers in binary format and vice versa
  • Describe and use the hexadecimal number system
  • Perform base conversions.


Activity 1 The format of number systems (60)

We use our fingers to count like a scale with 10 different levels (technically 11 if we start at zero but early civilisations didn't have a concept of zero).


This is why we use the Base 10 or Denary number system. However, if we use all 10 of our fingers, we are actually representing 1 lot of 10 and 0 units, so we don't really need to use our last finger ...


The Base 10 number system consists of 10 different values, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. This is the same for any number system - the base tells you how many symbols are available to represent things. This is OK up to Base 10 but what single character do we use to represent 10, 11, 12 etc?



Task 1.1 Counting
Counting.xlsm

Download the Counting.xlsm spreadsheet and investigate some different number systems.


Pay particular attention to the place values. Starting with Denary, this obvious (but only because we work in denary). In other number bases, the values of the places are different.

Write some notes in your books about numbers bases.

OUTCOME : Notes about number bases.


When we write numbers, we should always include the base they are in.  For instance, the number 1101 is ambiguous - I could assume that it's written in denary, but this may not be the case ...
  • 10102
  • 10108
  • 101010
  • 101016
... all represent different number of 'things' (10, 520, 1010 and 4112 things respectively).



Counting on your fingers (See this website)

Normally, when we count, we use each finger to represent just one 'thing'. This can be severely limiting when it comes to counting a large number of things because we quickly run out of fingers! How would it be different if we could use one finger to represent each available symbol in our base? That means we could use one finger to represent each place (and it's associated value) in the number rather than just one value.


Consider, then two situations ...

Click to enlarge

... which goes some way to explain why computers count in binary.

Activity 2 Why binary? (15)

So, why do computers use Binary? (Hint : because they are made of switches)

[Why Binary?]

Task 2.1 Why Binary
Engagement in activity

After you have carried out the activity, write about what you have found out.

OUTCOME : Written explanation of what you have found out from 'Why Binary?' activity


Activity 3 Binary - Denary Conversions (60)

Now that we understand the concept of place value, conversions are easy and best explained by example ...

Binary to Denary

[Your teacher may well demonstrate this as well]

Task 3.1 Binary to Denary conversions
Notebooks
Brain

Convert the following binary numbers to denary. Show your working.
  1. 000011012
  2. 000101112
  3. 000110102
  4. 010111002
  5. 101101012
OUTCOME : Binary to denary conversions with workings

Denary to Binary

[Your teacher may well demonstrate this as well]

Task 3.2 Denary to Binary conversions
Notebooks
Brain

Convert the following denary numbers into binary. Show all your working.
  1. 2910
  2. 3710
  3. 9610
  4. 7210
  5. 1210
OUTCOME : Denary to binary conversions with workings.


http://forums.cisco.com/CertCom/game/binary_game.swf
Click to play game

Activity 4 Hexadecimal (60)

Hexadecimal simply provides a convenient way of representing long binary strings.


One hexadecimal digit is used to represent 4 bits, or a nybble, in our binary string. For reference ...

Click to enlarge

Binary to hexadecimal conversion

[Your teacher may well demonstrate this as well]

Task 4.1 Binary to hexadecimal conversion
Notebooks
Brain

Convert (represent) the following binary strings to hexadecimal. Show all your working.
  • 100001102
  • 100100112
  • 1000010001002
  • 0100010010002
  • 101001102
OUTCOME : Binary to hexadecimal conversions with workings.


Hexadecimal to binary conversion

[Your teacher may well demonstrate this as well]

Task 4.2 Hexadecimal to binary conversion
Notebooks
Brain

Convert the following hexadecimal numbers to binary. Show all your working.
  • 8316
  • A916
  • 57216
  • 60416
  • ABC16
OUTCOME : Hexadecimal to binary conversions with working.


Extension Activities 

How about these?
  1. Binary to denary conversion program

    Write a program to input a binary number as a text string, convert it to denary and output the result. You may use the following algorithm:

    Output "Enter a binary number "
    Input BinaryString 
    BinaryLength ← Length of BinaryString
    Multiplier ← 1
    DenaryValue ← 0
    For n ← BinaryLength Down To 1
        Digit ← nth character in BinaryString
        DenaryValue ← DenaryValue + Digit * Multiplier
        Multiplier ← Multiplier * 2
    Next n
    Output "The denary equivalent is ", DenaryValue

    Note: Line seven requires a function that returns the nth character from a string. It may also need a function to convert this character to an integer.

    Could you adapt this so that it can handle different number bases?

  2. Denary to binary conversion program

    Write a program to input a denary number, convert it to binary and output the result. You may use the following algorithm which employs integer division:

    Output "Enter a denary number "
    Input DenaryValue
    BinaryString ← ""
    While DenaryValue > 0
        BinaryString ← CStr(DenaryValue MOD 2) + BinaryString
        DenaryValue ← DenaryValue DIV 2
    Endwhile
    Output "The binary equivalent is ", BinaryString

    Note: The function CStr converts a number to a string. The sign ‘+’ here represents concatenation.

  3. Poster competition

    Create a poster about binary : research and include simple binary rules, jokes, binary watches / clocks, comics …

  4. The Octal number system

    One other commonly used number system is Octal, or Base 8, since octal can be used to represent 3 bits where hexadecimal is used to represent 4. Read more about Octal on it's Wikipedia page. One particularly interesting fact is that the Yuki people from America count in Octal because they count using the gaps between the fingers rather than the fingers themselves.


What's next?

Before you hand your book in for checking, make sure you have completed all the work required and that your book is tidy and organised. Your book will be checked to make sure it is complete and you will be given a spicy grade for effort.

END OF TOPIC ASSESSMENT