#### Contents

- What are number bases?
- Why do we use different number bases in computer programming?

#### What are number bases?

A number base is a mathematical term which explains how to interpret a series of digits, as a numerical value.

Most of us will have been taught to use a base 10 numbering system, although you may not be aware of this. A base 10 numbering system means that each single digit will represent one of 10 possible values (0-9).

In school you probably learned that any number – let's take 2147 – can be broken down into columns to show that it is equal to 2x1000 + 1x100 + 4x10 + 7x1. These columns represent the orders of magnitude of our base number. The units column represents our base number of 10, with an exponent of 0. Our tens column represents our base number of 10 with an exponent of 1. This is shown in the table below.

Column | Thousands | Hundreds | Tens | Units |

Base^{order} |
10^{3} |
10^{2} |
10^{1} |
10^{0} |

Digit | 2 | 1 | 4 | 7 |

Value |
2x10 2000 |
1x10 100 |
4x10 40 |
7x10 7 |

#### Why do we use number bases in computer programming?

Put simply, a computer is a box full of complicated electronics. Fortunately only a very basic understanding is needed for computer programming. Where appropriate we will be demonstating basic principles using simple electronics circuits in order to give an easy to understand visual representation.

In the illustration above we can see that the circuit can only be in one of two states. When the switch is closed the lamp is on, and when the switch is open the lamp is off. In computer science we count these states as 0 representing off and 1 representing on.

Above we have modified the circuit by entering another switch and lamp, now we have a total of 4 different states. We have counted and displayed these states in the table below.

State count | Lamp 1 state | Lamp 0 state |

0 | 0 (off) | 0 (off) |

1 | 0 (off) | 1 (on) |

2 | 1 (on) | 0 (off) |

3 | 1 (on) | 1 (on) |

Due to the two basic states of a digital circuit this lends itself to representation in base 2, with each digit representing a single wire state of off or on (0 or 1 respectively). If we want to represent multiple wires then we can simply add an additional column to our number. Below is a table showing how 4 wires would be represented in base 10 (decimal) and base 2 (binary).

Decimal Value | Binary Value | Wire 3 | Wire 2 | Wire 1 | Wire 0 |

2^{3} |
2^{2} |
2^{1} |
2^{0} |
||

0 | 0000 | 0 | 0 | 0 | 0 |

1 | 0001 | 0 | 0 | 0 | 1 |

2 | 0010 | 0 | 0 | 1 | 0 |

3 | 0011 | 0 | 0 | 1 | 1 |

4 | 0100 | 0 | 1 | 0 | 0 |

5 | 0101 | 0 | 1 | 0 | 1 |

6 | 0110 | 0 | 1 | 1 | 0 |

7 | 0111 | 0 | 1 | 1 | 1 |

8 | 1000 | 1 | 0 | 0 | 0 |

9 | 1001 | 1 | 0 | 0 | 1 |

10 | 1010 | 1 | 0 | 1 | 0 |

11 | 1011 | 1 | 0 | 1 | 1 |

12 | 1100 | 1 | 1 | 0 | 0 |

13 | 1101 | 1 | 1 | 0 | 1 |

14 | 1110 | 1 | 1 | 1 | 0 |

15 | 1111 | 1 | 1 | 1 | 1 |