Welcome to Number Bases!
Hello! This chapter is the foundation of understanding how computers store and process every piece of data, from your favorite photo to the instructions in a game. It's all about how we count!
We use the Denary system every day, but computers need a simpler system based on electricity being either ON or OFF. This is where Binary and Hexadecimal come in.
Don't worry if this seems tricky at first! We will break down these complex ideas using simple analogies, making sure you can master these essential skills. Let's get started!
Why Do Computers Use Different Bases? (Data Representation Context)
You use the Denary system (Base 10) because you have ten fingers. Computers, however, are built from electronic switches. These switches can only be in one of two states:
- ON (meaning electricity is flowing)
- OFF (meaning electricity is not flowing)
This ON/OFF system is perfect for Binary, which uses only two digits: 1 and 0.
1. Denary (Base 10): The System We Know
Denary is the numbering system you use daily. It is also called Base 10 because it uses 10 different digits (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
Understanding Place Value
In Base 10, the position of a digit determines its value. These positions are powers of 10:
Example: The number 345
- 5 is in the \(10^0\) (Units) column = \(5 \times 1\) = 5
- 4 is in the \(10^1\) (Tens) column = \(4 \times 10\) = 40
- 3 is in the \(10^2\) (Hundreds) column = \(3 \times 100\) = 300
Denary is just the starting point, but understanding place value here is key to understanding Binary!
2. Binary (Base 2): The Computer's Language
Binary is the numbering system used by computers. It is called Base 2 because it uses only two digits: 0 and 1.
- A single Binary digit (a 0 or a 1) is called a Bit (Binary Digit).
- Eight Bits grouped together make a Byte.
Binary Place Values
Just like Denary uses powers of 10, Binary uses powers of 2. We usually work with 8 bits (one Byte) for standard data representation.
The place values for an 8-bit Binary number are:
\(2^7\), \(2^6\), \(2^5\), \(2^4\), \(2^3\), \(2^2\), \(2^1\), \(2^0\)
Which, when calculated, gives us the weights:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
Quick Review: Each 1 means the switch is ON (that value is counted). Each 0 means the switch is OFF (that value is ignored).
3. Converting Binary to Denary
This is often the easiest conversion! We use the place value columns we just learned.
Step-by-Step Conversion: Binary to Denary
Goal: Convert the Binary number 10110010 into Denary.
- Write out the 8-bit place values (weights):
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
- Place the Binary number underneath:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
1 | 0 | 1 | 1 | 0 | 0 | 1 | 0 - Identify the columns that have a '1' (the "ON" switches):
128, 32, 16, and 2
- Add the identified values together:
\(128 + 32 + 16 + 2 = 178\)
- State the final answer:
The Denary equivalent of 10110010 is 178.
Key Takeaway: Binary-to-Denary conversion is simply adding the place values where a '1' appears.
4. Converting Denary to Binary
This conversion requires figuring out which powers of 2 (which columns) are needed to make up the Denary number. We use the Subtraction Method.
Step-by-Step Conversion: Denary to Binary
Goal: Convert the Denary number 210 into Binary.
- Start with the largest possible place value (128):
Can we subtract 128 from 210? Yes.
210 - 128 = 82
Result: Put a 1 under the 128 column. - Move to the next column (64):
Can we subtract 64 from the remaining 82? Yes.
82 - 64 = 18
Result: Put a 1 under the 64 column. - Continue through the columns:
- 32: Can we subtract 32 from 18? No. (Put a 0)
- 16: Can we subtract 16 from 18? Yes. 18 - 16 = 2 (Put a 1)
- 8: Can we subtract 8 from 2? No. (Put a 0)
- 4: Can we subtract 4 from 2? No. (Put a 0)
- 2: Can we subtract 2 from 2? Yes. 2 - 2 = 0 (Put a 1)
- 1: The remaining number is 0. (Put a 0)
- Read the final Binary code:
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1
1 | 1 | 0 | 1 | 0 | 0 | 1 | 0
The Binary equivalent of 210 is 11010010.
Common Mistake to Avoid: Make sure you always check the subtraction against the *remaining* total, not the original number!
5. Hexadecimal (Base 16): The Shorthand
Binary is great for computers, but long strings of 1s and 0s are difficult for humans to read, write, and remember. They are prone to errors!
Hexadecimal (or Hex) is used as a shortcut. It is Base 16 because it uses 16 unique characters.
The 16 Hex Digits
Hex uses the digits 0 through 9, plus the letters A through F to represent values 10 through 15:
| Hex Digit | Denary Value | Binary Value (4 bits) |
|---|---|---|
| 0 | 0 | 0000 |
| ... | ... | ... |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Did you know? Hexadecimal is very common when dealing with memory addresses, error codes, and defining colours (like the web colour #FF0000 for pure red).
6. Conversions Between Binary and Hex
The beauty of Hex is that one single Hex digit is the perfect representation for four Binary bits (called a nibble).
Since one Byte is 8 bits, two Hex digits can perfectly represent one Byte.
A) Binary to Hexadecimal Conversion
Goal: Convert the Binary number 11011001 into Hex.
- Split the Binary number into groups of four bits (nibbles), starting from the right:
1101 | 1001
- Convert each nibble into its Denary equivalent:
- Group 1 (1101): \(8 + 4 + 0 + 1 = 13\)
- Group 2 (1001): \(8 + 0 + 0 + 1 = 9\)
- Convert the Denary values into their Hex equivalent:
- 13 in Hex is D
- 9 in Hex is 9
- Combine the Hex digits:
The Hex equivalent of 11011001 is D9.
B) Hexadecimal to Binary Conversion
This is the reverse process: take each Hex digit and write out its four-bit Binary code.
Goal: Convert the Hex number A5 into Binary.
- Handle the first digit (A):
A equals 10 in Denary. 10 in 4-bit Binary is 1010.
- Handle the second digit (5):
5 equals 5 in Denary. 5 in 4-bit Binary is 0101.
- Combine the two 4-bit groups:
The Binary equivalent of A5 is 10100101.
C) Denary to Hexadecimal Conversion
The easiest way to convert Denary to Hexadecimal (and back) is to use Binary as the middle step. This keeps the calculation methods simple and reduces errors.
Example: Convert Denary 150 to Hex:
- Denary 150 -> Binary: Using the subtraction method, you get 10010110.
- Binary 10010110 -> Hex: Split into nibbles: 1001 and 0110.
- 1001 is 9. 0110 is 6.
- Result: 96 (in Hex).
Quick Review of Number Bases
The Three Bases
- Denary (Base 10): Digits 0-9. Used by humans. Place values are powers of 10 (1, 10, 100...).
- Binary (Base 2): Digits 0, 1. Used by computers. Place values are powers of 2 (1, 2, 4, 8...).
- Hexadecimal (Base 16): Digits 0-9 and A-F. Used as a human-readable shorthand for Binary.
Memory Aid: Hex Letters
Remember that 'F' is the largest single Hex digit (15 in Denary, or 1111 in Binary).
Congratulations! You have now mastered the fundamental tools for data representation. Keep practicing those conversions—they are crucial exam skills!