# Binary

## What is Binary?

Some people think that our number system is based on tens because we have ten fingers, and we use our fingers to count. Computers don't have fingers, though - they have electrical circuits, and electrical circuits have two states, *on* or *off*. Computers, therefore, use a number system based on *twos* - this is called *binary*.

The two systems have a lot in common. In a number system based on **ten**s, often called *denary*, each column (units, tens, hundreds, etc.) has **ten** times the value of the column to its right, and each column can contain one of **ten** values (1-9 and 0). In a number system based on **two**s, each column heading has **two** times the value of the one to its right, and there can be **two** possible values in each position.

Below is a binary number (with the column headings added) and its denary equivalent:

Click a digit to toggle between 0 and 1. The denary value is the total of all of the headings with a 1 below. For example, 00001010 would mean we have one 16 and one 2, giving 00010010 a denary value of 18. It's as simple as that!

You are probably already familiar with different ways of writing down numbers - for example, *4*, *four*, *quatre* (French),
*vier* (German), *pedwar* (Welsh), *IIII* (tally), *IV* (Roman Numerals) and now *100*_{2} (binary) are all the same value; they're all one more than three and one less than five. Binary is just a way of recording numbers - after that they behave as normal.

## Investigate

Click to investigate. Can you make 100? Is there only one pattern of 0s and 1s that make each number? A sequence of eight bits (0s or 1s), like the one shown above, is called a *byte*. What is the maximum number that a byte can store? If you used your 10 fingers to count in binary, you could actually count up to 1023! For an alternative view of binary, you could try using the abacus in base 2. If you're wondering how we can represent numbers that aren't positive integers, have a look at the pages on binary fractions or normalised floating-point binary.

Once you are confident in converting to and from binary, why not practise your skills with the Binary Breakout game?

## Using Binary and Further Reading

We can take advantage of the fact that there is only one way to make each number by using something called *binary flags*. If, instead of 0s and 1s, we use two different colours, then we can also use binary to design a text character. Note also that when you count in binary, the bits in a column alternate between 0 and 1 with half the frequency of those in the column to its right. You can use this idea to help to you complete truth tables.

This page is aimed at the KS3 National Curriculum requirements for* Computing*. For a more in-depth discussion of number bases, look at the *Number Bases* page in the *Mathematics* section. You can also watch an introduction to binary and examples of how computers use binary on the *AdvancedICT* YouTube channel.

Why not practice your programming skills by creating a program that uses these techniques? Try to create a program that will convert a decimal number to binary - I can think of at least two ways to do it (one of which uses bitwise Boolean logic). There are binary/denary conversions on the Python programming examples page.