KS3 Computing/Binary

From Wikibooks, open books for an open world
Jump to navigation Jump to search


[edit | edit source]

Binary (Base2) and Decimal (Base10)

[edit | edit source]

When we count or measure something ourselves, we use the digits 0 to 9. Because there are ten digits we can use, this is Base10, usually called decimal (or sometimes denary).

A computer processor is made up of billions of switches, each of which, like a simple light switch, can be ON or OFF. We use 1s and 0s to represent the ONs and OFFs. Because there are only two possible values, we call this Base2, or Binary.

If I have a combination lock with three dials, each of which can be set to a number from 0-9, how many possible combinations are there?

3-barrel combination lock


There are 1000 combinations. But can you explain why?

(Don't worry if you can't, we'll cover it in a minute anyway.)

Activity: With three switches (or only the digits 0 and 1), work out how many possible combinations there are.

Try this out before you look at the answer below.

3-gang light switch


To work out the number of possible combinations for three switches, you might have used a table like this.

0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1

This gives us eight combinations. (If you got a different number, now is a good time to check if you missed one or duplicated one!)

If you add one more switch (four in total), now how many possible combinations are there?


Four switches gives us sixteen combinations. Can you see a pattern and work out how many we would get with eight or sixteen or a hundred switches?

So we know that a lock with three dials, each with ten possible positions, give us a thousand combinations, and three switches with two possible positions give us eight combinations. But why is this?

With three columns, each with ten possibilities, the number of total combinations is 10 × 10 × 10, or 1000.

With three switches, each with two possibilities, the number of total combinations is 2 × 2 × 2, or 8.

Raising to a Power - When we multiply ten by itself three times (10 × 10 × 10) we call this ten raised to the power of three (or ten to the power of three or ten to the three) which we write as 10³.

In computing, for example in spreadsheet formulas and programming, we type 10^3 which means exactly the same thing but is easier to find on the keyboard.

(The ^ symbol is called a caret. On English keyboards you get it by pressing Shift and the number 6.)

For any number of dials and any number of positions on the dial, the number of possible combinations is always aᵇ, where a is the number of positions on the dial and b is the number of dials.

Now can you work out how many combinations we'd get with a eight, sixteen or a hundred switches?


Eight switches gives us 256, sixteen gives 65,536 and a hundred gives us 1,267,650,600,228,229,401,496,703,205,376.

Aren't you glad you don't have to write all those out in a table?

Bits and bytes

[edit | edit source]

So now we know that binary is just a number system which uses the digits 0 and 1.

In computing, we call the number of switches or columns bits (this comes from binary digits.) So a number like 1011 we would say has 4 bits.

Bit - A single 1 or 0; a binary digit

Byte - Eight bits

When you look at file sizes on your computer, you'll usually see them reported in these units:

bytes (B)
kilobytes (KB) 1 KB = 1024 B
megabytes (MB) 1 MB = 1024 KB = 1,048,576 B
gigabytes (GB) 1 GB = 1024 MB = 1,048,576 KB = 1,073,741,824 B

Why do we multiply by 1024...

[edit | edit source]

...when kilo usually means multiply by a thousand (e.g. kilometers, kilogrammes)?

There are two answers to this question...

Easy answer: remember how we said that powers of two come up again and again in computing? Well, 1024 is 210.

Harder answer: sometimes it isn't, sometimes it's 1000 after all. See Wikipedia's page about the Kilobyte. But don't worry about it too much, when your computer tells you how big a file is, its Kilobytes are 1024 bytes, its Megabytes are 1024 Kilobytes and so on.

Watch out for megabits vs. megabytes!

[edit | edit source]

If you want to download some music tracks that are 50MB in total, and your broadband is working at 5Mbps, how long would the download take?


If you said 10 seconds, look closely at the Mbps unit for the download speed. In this case it means megabits per second. Data transfer rates (e.g.download speeds) are usually measured in bits, kilobits, megabits, gigabits, etc. per second.

Have another think, then click on the next answer to see if you were right.


1 Byte = 8 bits so 50 MegaBytes = 400 Megabits

400 Megabits ÷ 5 Megabits per second = 80 seconds.

So a 50MB download at 5Mbit/s would take 80 seconds or 1 minute 20 seconds.

Binary Numbers

[edit | edit source]

When we learn to add or multiply in decimal, we use columns of (from right to left) Units, Tens, Hundreds, Thousands, and so on. The value of each column is ten times the column on its right.

Adding Hundreds, Tens and Units

Can you work out what the columns would be in binary?


In binary, each column is two times the column on its right. So for an 8-bit number the columns are:

128, 64, 32, 16, 8, 4, 2, 1

Powers of two - In the same way that you use the powers of ten (1, 10, 100, 1000) all the time with decimal numbers, in binary the powers of two are everywhere.

The first eight powers of two are:

Working with binary you will get to know these numbers very well!

(Needs a section here about converting Dec2Bin and Bin2Dec)

Counting in Binary

[edit | edit source]

What number can you count to on the fingers of one hand?


Most people answer five, but keep reading...

What number can you count to in binary on the fingers of one hand? (Each finger can be 'up' or 'down' for 'on' or 'off, 1 or 0. With some practice, the fingers of one hand can be a five-bit binary counter!)

This counter shows how to count in binary from numbers zero through thirty-one.

(Add a gif of counting in binary on one hand)


On the fingers of one hand, you can count to 31. Look at the gif above and try it!

Activity: In groups of four, act out three-bit binary counter. Three people will be the bits, one person will need to direct.

  1. Three people should sit in a row, in chairs - this represents 0 0 0.
  2. To represent 0 0 1, the person on the right should stand up.
  3. For 0 1 0 , the person on the right should sit down and the person in the middle should stand up.
  4. Use the table from the first exercise to work through the values 0 to 7

What patterns do you notice? With practice, can your director join in so you become a four-bit counter?

(The person on the far right might want to swap places before their legs hurt from all the standing and sitting!)

Extension: Can you write an algorithm that anyone in the human binary counter could follow, regardless of how many digits there are, or which position they're in?

Sources and more reading

[edit | edit source]

Some of the materials came from Wikipedia, however they may have been edited to suit the main audience of this book (Key Stage 3 pupils aged between 11 and 14)