Number Systems and Operations
TL;DR
You'll learn about different ways computers represent numbers, focusing on binary, denary (decimal), and hexadecimal. We'll cover how to convert between these systems and perform basic operations like addition. Understanding these concepts helps you grasp how computers process information at a fundamental level.
1. The Mental Model
Think of numbers as being spoken in different languages. Denary is your everyday language. Binary is what computers speak. Hexadecimal is a helpful shortcut for humans to understand binary.
2. The Core Material
Computers use binary (base 2) because their circuits are either on or off, representing 1 or 0. Humans are used to denary (base 10), using digits 0-9. Hexadecimal (base 16) is a compact way to represent binary, using digits 0-9 and letters A-F.
Converting Between Number Systems
Binary to Denary:
Each digit in a binary number represents a power of 2, starting from 2^0 on the far right. You multiply each binary digit by its corresponding power of 2 and add the results.
Example: Convert 1011 (binary) to denary.
1 * 2^3 + 0 * 2^2 + 1 * 2^1 + 1 * 2^0
1 * 8 + 0 * 4 + 1 * 2 + 1 * 1
8 + 0 + 2 + 1 = 11 (denary)
Denary to Binary:
You can use a repeated division method. Divide the denary number by 2, record the remainder, then divide the quotient by 2, and so on, until the quotient is 0. Read the remainders from bottom to top.
Example: Convert 13 (denary) to binary.
13 / 2 = 6 remainder 1
6 / 2 = 3 remainder 0
3 / 2 = 1 remainder 1
1 / 2 = 0 remainder 1
Reading remainders bottom-up: 1101 (binary)
Hexadecimal to Binary:
Each hexadecimal digit directly corresponds to a 4-bit binary number.
| Hex Digit |
Binary |
Denary |
| 0 |
0000 |
0 |
| 1 |
0001 |
1 |
| ... |
... |
... |
| 9 |
1001 |
9 |
| A |
1010 |
10 |
| B |
1011 |
11 |
| C |
1100 |
12 |
| D |
1101 |
13 |
| E |
1110 |
14 |
| F |
1111 |
15 |
Example: Convert A5 (hex) to binary.
A = 1010
5 = 0101
So, A5 (hex) = 10100101 (binary)
Binary to Hexadecimal:
Group the binary digits into sets of 4, starting from the right. Convert each 4-bit group into its corresponding hexadecimal digit. Add leading zeros if your leftmost group has fewer than 4 bits.
Example: Convert 11010110 (binary