1.1A Binary, Denary and Hexadecimal
In this lesson, you will learn how computers represent numbers using different number systems. We will focus on denary, binary, and hexadecimal.
By the end of this section, you should be able to:
- Explain what denary, binary, and hexadecimal number systems are.
- Understand the importance of place value.
- Convert binary numbers to denary.
- Convert denary numbers to binary.
- Explain why hexadecimal is useful in computer science.
Denary Numbers
The denary number system is the number system we use in everyday life. It is also called the decimal system.
It is a base-10 system, which means it uses ten different digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
Place Value
The value of a number depends on the position of each digit. Each position represents a power of 10.
Starting from the right, the place values increase as:
1, 10, 100, 1000, ...
This means that each step to the left is worth ten times more than the previous one.
Example
Consider the number 572.
| Place value | 100 | 10 | 1 |
|---|---|---|---|
| Digit | 5 | 7 | 2 |
| Value | 500 | 70 | 2 |
So the number can be written as:
572 = 500 + 70 + 2
This shows how each digit contributes to the overall value depending on its position.
Binary Numbers
Binary is a base-2 number system. This means it only uses two digits: 0 and 1.
Like denary numbers, binary numbers use place value. However, instead of powers of 10, binary uses powers of 2.
For example, the binary number 110101 can be broken down like this:
| Place value | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|
| Binary digit | 1 | 1 | 0 | 1 | 0 | 1 |
| Value | 32 | 16 | 0 | 4 | 0 | 1 |
So 110101β = 32 + 16 + 4 + 1 = 53ββ.
Computers use binary because computer hardware is designed around two possible states, such as on/off or true/false. These two states can be represented naturally using 1 and 0.
Binary data is often organised into groups of eight bits. For example: 01101001 is one byte.
Hexadecimal Numbers
Hexadecimal is a base-16 number system. This means it uses sixteen different symbols to represent values.
The digits 0β9 are used as usual, and the letters AβF are used to represent values greater than 9.
| Hex | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Denary | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
Like other number systems, hexadecimal uses place values. Each position represents a power of 16, so moving one place to the left increases the value by a factor of 16.
A single hexadecimal digit corresponds exactly to four binary digits. Because of this, hexadecimal provides a more compact way of writing binary values.
Since a byte contains eight bits, it can be represented using two hexadecimal digits.
| Binary | Hexadecimal | Denary |
|---|---|---|
| 00101100 | 2C | 44 |
| 11001010 | CA | 202 |
When working on paper, leading zeros in binary are often omitted. However, when data is stored in a computer, each byte must always contain eight bits, so zeros may be added at the beginning to keep the correct length.
Hexadecimal is widely used in computing because it is easier for humans to read and write than long binary sequences. It is commonly seen in memory addresses, error codes, and data representations such as colour values.
Try it yourself: Number System Converter
Type a value in one box. The other number systems will update automatically.
Conversions
Binary to denary
To convert binary to denary, add the place values where the binary digit is 1.
Example: 1011010β = 64 + 16 + 8 + 2 = 90ββ.
Denary to binary
To convert denary to binary, find the largest power of 2 that fits into the number, subtract it, and repeat until the number is fully represented.
Example: 93ββ = 64 + 16 + 8 + 4 + 1, so 93ββ = 1011101β.
Binary to hexadecimal
To convert binary to hexadecimal, split the binary number into groups of four bits from the right, then convert each group into one hexadecimal digit.
Interactive: Denary and Binary Step Visualiser
Use this tool to see how a denary number is changed into binary. You can compare two common methods: repeated division by 2, or selecting powers of 2.
Interactive: Binary to Hexadecimal
Enter a binary value. The tool will group the bits into nibbles and show how each group becomes one hexadecimal digit.
Interactive: Denary to Hexadecimal
Enter a denary number. The tool divides by 16 step by step and shows how the hexadecimal answer is formed from the remainders.
Practice
Try these questions
- Convert 111000β to denary.
- Convert 86ββ to binary.
- Convert 10110111β to hexadecimal.
- Convert D5ββ to denary.
- Explain why hexadecimal is useful for representing binary data.