Introduction
Welcome to the world of Number Systems! You might think you know everything about numbers—after all, you’ve been using them since you were a toddler. But in Computer Science, we look at numbers a bit differently. Computers don’t "see" the number 10 the same way we do; they see a series of electrical signals. In this chapter, we are going to explore the different "sets" of numbers and the "bases" (like Binary and Hexadecimal) that allow computers to represent everything from a simple text message to a high-definition video. Don't worry if it feels like a lot of math at first—we'll break it down step-by-step!
1. The Different Sets of Numbers
In the AQA syllabus, you need to know which "club" a number belongs to. Mathematicians group numbers into sets based on their properties. Think of these like Russian nesting dolls, where one set often fits inside another.
Natural Numbers \((\mathbb{N})\)
These are the "counting numbers." If you can count objects on your fingers, they are natural numbers.
Example: 0, 1, 2, 3, 100...
Note: In AQA Computer Science, we include zero in the set of Natural Numbers.
Memory Tip: N is for Natural, like the things you find in Nature (you can have 1 tree or 2 birds).
Integer Numbers \((\mathbb{Z})\)
Integers are whole numbers. This set includes all the natural numbers, but it adds negative numbers too.
Example: -3, -2, -1, 0, 1, 2...
Memory Tip: Think of a temperature scale. It can be 5 degrees or -5 degrees, but it's always a whole number.
Rational Numbers \((\mathbb{Q})\)
Rational numbers are values that can be written as a fraction (a ratio). If you can write it as \( \frac{a}{b} \), it’s rational.
Example: \( \frac{1}{4} \), \( 0.5 \) (which is \( \frac{1}{2} \)), or even \( 7 \) (which is \( \frac{7}{1} \)).
Quick Review: Every integer is also a rational number because you can just put it over 1!
Irrational Numbers
These are the "wild" numbers. They cannot be written as a simple fraction. When written as decimals, they go on forever without repeating a pattern. Example: \( \sqrt{2} \), \( \pi \) (Pi).
Real Numbers \((\mathbb{R})\)
This is the "master set." It includes all of the above: natural numbers, integers, rational, and irrational numbers. Basically, any value that represents a "real-world" quantity is a Real Number.
Ordinal Numbers
These aren't about "how much," but rather "which position." We use these to describe the order of items in a list.
Example: 1st, 2nd, 3rd...
Analogy: In a race, the number of runners is a Natural Number (e.g., 10 runners), but the person who wins is in 1st place (an Ordinal Number).
Quick Review Box:
- Natural \(\mathbb{N}\): Counting (0, 1, 2...)
- Integer \(\mathbb{Z}\): Whole numbers (includes negatives)
- Rational \(\mathbb{Q}\): Fractions
- Real \(\mathbb{R}\): Any measurement on a continuous scale
- Ordinal: Position (1st, 2nd...)
Takeaway: Computers use different sets for different tasks. We use Natural numbers for counting items and Real numbers for precise measurements.
2. Counting vs. Measurement
It sounds simple, but there is a key distinction here for your exam:
1. Counting uses Natural Numbers. These are discrete data—you can't have 2.5 people in a room.
2. Measurement uses Real Numbers. These are continuous data—you can be 175.5 cm tall, or even 175.523 cm if your ruler is good enough!
Did you know? Computers struggle with Real numbers because they can have infinite decimal places. Computers have to "round" them, which can sometimes lead to tiny errors in complex calculations!
3. Number Bases
A base is just the number of digits available in a counting system. While humans love Base 10, computers prefer Base 2.
Decimal (Base 10)
This is what you use every day. It uses 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. Once you hit 9, you "carry the one" to the next column.
Binary (Base 2)
The native language of computers. It uses only 2 digits: 0 and 1. Each "bit" (binary digit) represents a switch being OFF or ON.
Hexadecimal (Base 16)
This uses 16 symbols. Since we ran out of numbers after 9, we use letters! 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A(10), B(11), C(12), D(13), E(14), F(15).
Why use Hexadecimal?
It is much easier for humans to read than long strings of binary. For example, the color "White" in a computer is 11111111 11111111 11111111 in binary, but just FFFFFF in Hex. It acts as a shorthand for binary.
Takeaway: Binary is for computers, Decimal is for humans, and Hexadecimal is a shorthand to help humans understand computer data.
4. Converting Between Bases
You will definitely be asked to convert numbers in your exam. Here is the easiest way to do it.
Binary to Decimal
1. Draw a table with the powers of 2 (starting from the right).
2. Put your binary number in the table.
3. Add up the numbers where there is a "1".
Example: Convert 1011 to Decimal
(8) | (4) | (2) | (1)
1 | 0 | 1 | 1
\( 8 + 0 + 2 + 1 = 11 \)
Decimal to Binary
1. Keep subtracting the largest power of 2 that "fits" into your number.
Example: Convert 13 to Binary
- Does 16 fit? No (0)
- Does 8 fit? Yes. \( 13 - 8 = 5 \). (Write a 1)
- Does 4 fit? Yes. \( 5 - 4 = 1 \). (Write a 1)
- Does 2 fit? No. (Write a 0)
- Does 1 fit? Yes. \( 1 - 1 = 0 \). (Write a 1)
Result: 1101
Binary to Hexadecimal
This is a student favorite because it's so fast!
1. Split your binary number into groups of 4 bits (starting from the right).
2. Convert each 4-bit group into its Hex value.
Example: Convert 10101111 to Hex
- Group 1: 1010 (which is 10, or A)
- Group 2: 1111 (which is 15, or F)
Result: AF
Common Mistake: When converting to Hex, don't forget that 10 is A, not 10! If you write "10F" instead of "AF", the computer will think you've written a completely different number.
Takeaway: Always use a grid for binary conversions! It prevents simple addition mistakes and keeps your work organized for the examiner to see.
Quick Review: Chapter Summary
- Sets: \(\mathbb{N}\) (Natural), \(\mathbb{Z}\) (Integer), \(\mathbb{Q}\) (Rational), \(\mathbb{R}\) (Real).
- Ordinal: Tells you the position in a list.
- Counting: Natural numbers. Measuring: Real numbers.
- Bases: Binary (2), Decimal (10), Hexadecimal (16).
- Hex shorthand: One Hex digit represents exactly four binary bits (a nibble).