A-level Computing/AQA/Paper 2/Fundamentals of data representation/Number bases
Number Bases
Template:CPTSpecification Be familiar with the concept of a number base, in particular:
- decimal (base 10)
- binary (base 2)
- hexadecimal (base 16).
Convert between decimal, binary and hexadecimal number bases.
Template:Robox/Close
Before we jump into the world of number systems we'll need a point of reference, I recommend that you copy the following table that you can refer to throughout this chapter to check your answers.
| Hexadecimal | Binary | Denary |
|---|---|---|
| 0 | 0000 | 0 |
| 1 | 0001 | 1 |
| 2 | 0010 | 2 |
| 3 | 0011 | 3 |
| 4 | 0100 | 4 |
| 5 | 0101 | 5 |
| 6 | 0110 | 6 |
| 7 | 0111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
| 10 | 0001 0000 | 16 |
Denary/Decimal
Denary is the number system that you have most probably grown up with. It is also another way of saying base 10. This means that there are 10 different numbers that you can use for each digit, namely:
0,1,2,3,4,5,6,7,8,9
Notice that if we wish to say 'ten', we use two of the numbers from the above digits, 1 and 0.
| Thousands | Hundreds | Tens | Units |
|---|---|---|---|
| 103 | 102 | 101 | 100 |
| 1000 | 100 | 10 | 1 |
| 5 | 9 | 7 | 3 |
Using the above table we can see that each column has a different value assigned to it. And if we know the column values we can know the number, this will be very useful when we start looking at other base systems. Obviously, the number above is: five-thousands, nine-hundreds, seven-tens and three-units.
5*1000 + 9*100 + 7*10 + 3*1 = 597310
Binary
Binary is a base-2 number system, this means that there are two numbers that you can write for each digit:
0, 1
With these two numbers we should be able to write (or make an approximation of) all the numbers that we could write in denary.
| One-hundred and twenty-eights | Sixty-fours | Thirty-twos | Sixteens | Eights | Fours | Twos | Units |
|---|---|---|---|---|---|---|---|
| 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 |
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 0 | 1 | 1 | 0 | 1 | 0 | 1 | 0 |
Using the above table we can see that each column has a value assigned to it that is the power of two (the base number!), and if we take those values and the corresponding digits we can work out the value of the number: 1*64 + 1*32 + 1*8 + 1*2 = 106.
If you are asked to work out the value of a binary number, the best place to start is by labelling each column with its corresponding value and adding together all the columns that hold a 1. Let's take a look at another example:
000111112
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 |
So now all we need to do is to add the columns containing 1s together: 1*16 + 1*8 + 1*4 + 1*2 + 1*1 = 31
Template:CPTExercise Template:CPTQuestion Template:CPTAnswerTab
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
8+4 = 1210
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 |
64 + 16 + 8 + 1 = 8910
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
4 + 2 + 1 = 710
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 |
64 + 16 + 4 + 1 = 8510
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswer Template:CPTQuestion Template:CPTAnswerTab Yes, take the first 0's column value and minus one
| 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
= 128 - 1 = 127 = 64 + 32 + 16 + 8 + 4 + 2 + 1
000011112 = 16 - 1 = 15 = 8 + 4 + 2 + 1
000001112 = 8 - 1 = 7 = 4 + 2 + 1
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswer Template:Robox/Close
Hexadecimal
Template:CPTSpecification Be familiar with, and able to use, hexadecimal as a shorthand for binary and to understand why it is used in this way. Template:Robox/Close
You may notice from the table that one hexadecimal digit can represent exactly 4 binary bits. Hexadecimal is useful to us as a shorthand way of writing binary, and makes it easier to work with long binary numbers.
Counting is a fundamental concept using symbols to represent groups of objects. We are used to counting using 10 such symbols, 0-9. When we run out of symbols we start a new column of numbers to represent a bigger collection of values. There are other ways of counting that use a different number of symbols, however, the counting process operates in the same manner.
Hexadecimal is a base-16 number system which means we will have 16 different numbers to represent our digits. The only problem being that we run out of numbers after 9, and knowing that 10 is counted as two digits we need to use letters instead:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
We can do exactly the same thing as we did for denary and binary, and write out our table.
| 165 | 164 | 163 | 162 | 161 | 160 |
|---|---|---|---|---|---|
| 1 048 576 | 65536 | 4096 | 256 | 16 | 1 |
| 0 | 0 | 3 | 4 | A | F |
So now all we need to do is to add the columns containing values together, but remember that A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
3*4096 + 4*256 + (A)10*16 + (F)15*1 = 1348716
You might be wondering why we would want to use hexadecimal when we have binary and denary, and when computers store and calculate everything in binary. The answer is that it is entirely for human ease. Consider the following example:
| Representation | Base |
|---|---|
| EFFE1116 | base-16 hexadecimal |
| 1572814510 | base-10 denary |
| 1110111111111110000100012 | base-2 binary |
All the numbers are the same and the easiest version to remember/understand for humans is the base-16. Hexadecimal is used in computers for representing numbers for human consumption, having uses for things such as memory addresses, error or colour codes. NOTE: Hexadecimal is used as it is shorthand for binary and easier for people to remember. It DOES NOT take up less space in computer memory, only on paper or in your head! Computers still have to store everything as binary even if it appears as hexadecimal on the screen.


Template:CPTExercise Template:CPTQuestion Template:CPTAnswerTab
16 1 A 1 16 * 10 + 1 * 1 = 16110
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
16 1 F F 16 * 15 + 1 * 15 = 25510
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
16 1 0 D 16 * 0 + 1 * 13 = 1310
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
16 1 3 7 16 * 3 + 1 * 7 = 5510
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswer Template:CPTQuestion Template:CPTAnswer Template:Robox/Close
Converting Between Bases
The sum that you saw previously to convert from hex to denary seemed a little cumbersome and in the exam you wouldn't want to make any errors, we therefore have to find an easier way to make the conversion.
Since 4 binary bits are represented by one hexadecimal digit, it is simple to convert between the two. You can group binary bits into groups of 4, starting from the right, and adding extra 0's to the left if required, and then convert each group to their hexadecimal equivalent. For example, the binary number 01101100111101012 can be written like this:
0110 1100 1111 0101
and then by using the table above, you can convert each group of 4 bits into hexadecimal:
0110 1100 1111 0101 6 C F 5
So the binary number 01101100111101012 is 6CF516 in hexadecimal. We can check this by converting both to denary. First we'll convert the binary number, since you already know how to do this:
| 32768 | 16384 | 8192 | 4096 | 2048 | 1024 | 512 | 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 |
By multiplying the columns and then adding the results, the answer is 2789310.
Notice that the column headings are all 2 raised to a power, , , , , and so on. To convert from hexadecimal to denary, we must use column headings that are powers with the base 16, like this:
| 4096 | 256 | 16 | 1 |
|---|---|---|---|
| 6 | C | F | 5 |
(You should memorize the values A-F)
Totalling them all up gives us 2789310, showing that 01101100111101012 is equal to 6CF516.
To convert from denary to hexadecimal, it is recommended to just convert the number to binary first, and then use the simple method above to convert from binary to hexadecimal.
In summary, to convert from one number to another we can use the following rule: Hexadecimal <-> Binary <-> Denary

Template:ExerciseRobox Template:CPTQuestion Template:CPTAnswerTab
1 2 (Hex) 0001 0010 (Binary) 128 64 32 16 8 4 2 1 0 0 0 1 0 0 1 0 = 16+2 = 1810 (decimal)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
A 5 (Hex) 1010 0101 (Binary) 128 64 32 16 8 4 2 1 1 0 1 0 0 1 0 1 = 128+32+4+1 = 16510 (decimal)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
7 F (Hex) 0111 1111 (Binary) 128 64 32 16 8 4 2 1 0 1 1 1 1 1 1 1 = 64+32+8+4+2+1 = 12710 (decimal)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
1 0 (Hex) 0001 0000 (Binary) 128 64 32 16 8 4 2 1 0 0 0 1 0 0 0 0 = 1610 (decimal)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
1010 1101 (Binary) A D (Hex)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
0011 0111 (Binary) 3 7 (Hex)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
1010 1111 (Binary) A F (Hex)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
1110 1010 0001 (Binary) E A 1 (Hex)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
128 64 32 16 8 4 2 1 0 1 0 1 0 1 1 1 = 64+16+4+2+1 = 8710 (decimal)
0101 0111 (Binary) 5 7 (Hex)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
128 64 32 16 8 4 2 1 0 0 0 0 1 1 0 0 = 8+4 = 12(decimal)
0000 1100 (Binary) 0 C (Hex)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswerTab
128 64 32 16 8 4 2 1 0 1 1 1 0 1 0 1 = 64+32+16+4+1 = 117(decimal)
0111 0101 (Binary) 7 5 (Hex)
Template:CPTAnswerTabEnd Template:CPTQuestion Template:CPTAnswer Template:CPTQuestion Template:CPTAnswer Template:Robox/Close Template:BookCat