Lesson
Denary (or decimal) is base-10 and is the number system we are most familiar with. We have the columns of units, tens, hundreds, thousands and so on. Base-10 means that we have 10 possible values (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) in each column.
Binary is base-2 and has 2 values, 0 and 1. It requires a greater number of digits in binary to represent a number than denary. This is how data and instructions are stored in a computer.
To calculate the maximum value for a given number of bits we use 2n-1 where n is the number of bits. For example for 4 bits we have 24-1 which is 15.
Bits | Max value binary | Max value denary |
---|---|---|
1 | 12 | 110 |
2 | 112 | 310 |
3 | 1112 | 710 |
4 | 11112 | 1510 |
5 | 111112 | 3110 |
6 | 1111112 | 6310 |
7 | 11111112 | 12710 |
8 | 111111112 | 25510 |
Hexadecimal is base-16. To make up the 16 values we use the ten denary numbers in addition to 6 letters (A, B, C, D, E, F).
Denary | Hex. | Binary |
---|---|---|
010 | 016 | 00002 |
110 | 116 | 00012 |
210 | 216 | 00102 |
310 | 316 | 00112 |
410 | 416 | 01002 |
510 | 516 | 01012 |
610 | 616 | 01102 |
710 | 716 | 01112 |
Denary | Hex. | Binary |
---|---|---|
810 | 816 | 10002 |
910 | 916 | 10012 |
1010 | A16 | 10102 |
1110 | B16 | 10112 |
1210 | C16 | 11002 |
1310 | D16 | 11012 |
1410 | E16 | 11102 |
1510 | F16 | 11112 |
Hexadecimal is used a lot in computing because it much easier to read than binary. There are far fewer characters than binary. So hexadecimal is often used in place of binary as a shorthand to save space. For instance, the hexadecimal number 7BA3D456 (8 digits) is 0111 1011 1010 0011 1101 0100 0101 0110 (32 digits) in binary which is hard to read.
Hexadecimal is better than denary at representing binary because hexadecimal is based on powers of 2.
Learning Videos
For more information click on the tab below to watch a video about the lesson.
Click here for video - Number bases
Click here for video - Bit patterns
Click for video - Why hexadecimal is used in computer science
Questions
-
Give one reason why data is represented in binary in a computer.
The digits 1 and 0 can be represented by a switch being ON or OFF
-
The smallest number, in decimal, that can be stored in an 8-bit binary number.
0000 0000 (or 0)
-
The largest number, in decimal, that can be stored in an 8-bit binary number.
255
-
For the binary number 0110 1101, what is the most significant bit?
0 (the furthest left)
-
For the binary number 0110 1101, what is the least significant bit?
1 (the furthest right)
-
Colours in art packages are often given using hexadecimal as illustrated below with #2d462d.
Explain why hexadecimal is used rather than the actual 24-bit colour value.
It is easier for designers and software users to remember/write hex code rather than a binary value of 24 bits.
The code only takes up six digits on the screen rather than 24 so it is more easily displayed on the GUI.
It is quicker/shorter/less prone to error to enter a six-character hexadecimal value to reproduce an exact colour than it is to enter a long binary value.
Go Back