Welcome to Number Bases!
Ever wondered how a computer, which is basically just a collection of electronic circuits, can show you a high-definition movie or play your favorite game? It all starts with Number Bases. In this chapter, we will explore the three main ways we represent numbers in Computer Science: Decimal, Binary, and Hexadecimal.
Don't worry if this seems a bit "maths-heavy" at first. Once you learn the patterns, it’s like cracking a secret code!
1. The Three Main Bases
A "base" simply tells us how many digits are available in a counting system. For the AQA 8525 syllabus, you need to know these three:
Decimal (Base 10)
This is the system you’ve used since primary school. It uses ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
Analogy: Think of your ten fingers! We count to nine, and when we hit ten, we move to a new "place value" column.
Binary (Base 2)
This is the computer's native language. It uses only two digits: 0 and 1.
Did you know? Computers use binary because they are made of billions of tiny switches called transistors. A switch can only be OFF (0) or ON (1).
Hexadecimal (Base 16)
This system uses sixteen digits. Because we ran out of normal numbers after 9, we use letters!
Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.
In Hex, A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15.
Quick Review:
• Decimal: Base 10 (0-9)
• Binary: Base 2 (0-1)
• Hexadecimal: Base 16 (0-F)
2. Why do we use Hexadecimal?
If computers "think" in binary, why do humans bother with Hexadecimal? Imagine trying to read this: 1011101011010001. It’s easy to make a mistake!
Hexadecimal is used because:
1. It is shorter and easier for humans to read than long strings of binary.
2. There is less chance of making errors when copying values.
3. It is very easy to convert between Binary and Hex (as 1 Hex digit represents exactly 4 bits).
Real-world example: You’ll see Hex codes used for HTML colors (like #FF5733) or MAC addresses on your phone.
3. Converting Binary to Decimal
To convert binary to decimal, we use a place value table. In binary, the values double every time you move to the left.
Step-by-Step: Convert 10101100 to Decimal
1. Draw a table with 8 columns, starting from the right with 1 and doubling as you go left:
\( 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 \)
2. Put your binary number into the table:
\( 128(1) | 64(0) | 32(1) | 16(0) | 8(1) | 4(1) | 0(0) | 0(0) \)
3. Add up the values where there is a 1:
\( 128 + 32 + 8 + 4 = 172 \)
Key Takeaway: If there is a 1 in the column, "turn on" that number and add it to your total!
4. Converting Decimal to Binary
There are two main ways to do this, but the "Subtraction Method" is often the simplest.
Step-by-Step: Convert 75 to Binary
1. Keep your place value table handy: \( 128, 64, 32, 16, 8, 4, 2, 1 \).
2. Start from the left (128). Does 128 fit into 75? No (Put a 0).
3. Does 64 fit into 75? Yes! (Put a 1). Now subtract it: \( 75 - 64 = 11 \).
4. Does 32 fit into 11? No (Put a 0).
5. Does 16 fit into 11? No (Put a 0).
6. Does 8 fit into 11? Yes! (Put a 1). Subtract it: \( 11 - 8 = 3 \).
7. Does 4 fit into 3? No (Put a 0).
8. Does 2 fit into 3? Yes! (Put a 1). Subtract it: \( 3 - 2 = 1 \).
9. Does 1 fit into 1? Yes! (Put a 1).
Result: 01001011
Common Mistake: Always make sure your binary number has 8 bits (one byte) if the question asks for it, even if there are leading zeros!
5. Converting between Binary and Hexadecimal
This is the "magic trick" of Computer Science. Because \( 2^4 = 16 \), exactly four binary bits (called a nibble) match up to one hexadecimal digit.
Step-by-Step: Binary to Hex (Example: 10110110)
1. Split the 8-bit number into two 4-bit nibbles: 1011 and 0110.
2. Calculate the decimal value of the first nibble (8-4-2-1): \( 8+2+1 = 11 \).
3. Convert 11 to Hex: \( 11 = B \).
4. Calculate the second nibble: \( 4+2 = 6 \).
5. Join them together: B6.
Step-by-Step: Hex to Binary (Example: 2F)
1. Take the first digit (2) and turn it into a 4-bit binary number: 0010.
2. Take the second digit (F) and remember \( F = 15 \). Turn 15 into 4-bit binary: 1111.
3. Join them: 00101111.
Memory Aid: Use the 8-4-2-1 rule for every nibble!
6. Summary Table of Maximum Values
The AQA syllabus requires you to know values between 0 and 255. Here is how that looks in different bases:
Decimal: 255
Binary: 1111 1111 (Eight 1s)
Hexadecimal: FF
Don't worry if this seems tricky at first! The best way to learn is to draw out the 128-64-32-16-8-4-2-1 table and practice with your own age, house number, or favorite number.
Final "Quick Review" Box:
• Bit: A single 0 or 1.
• Nibble: 4 bits (1 Hex digit).
• Byte: 8 bits (2 Hex digits).
• Base 10 to Base 16: Easiest way is usually Decimal $\rightarrow$ Binary $\rightarrow$ Hex.