Welcome to the World of Bases!
Hello future Computer Scientists! This chapter, Converting between Number Bases, is fundamental to understanding how computers store and process information. Don't worry if the numbers look strange at first—it's like learning a new language. Once you master the rules, you’ll be translating instantly!
In this chapter, we will learn how to convert numbers between the three main bases used in computing: Denary (Base 10), Binary (Base 2), and Hexadecimal (Base 16).
Why do we need different bases?
We use Denary (Base 10) because we have 10 fingers (a handy coincidence!). Computers, however, only understand electricity—either ON or OFF. This ON/OFF state is represented by 1 and 0, which is why they use Binary (Base 2). Hexadecimal (Base 16) is just a convenient shorthand for programmers to read long strings of Binary quickly!
The Three Essential Number Bases
1. Denary (Base 10)
This is the standard number system we use every day. It uses 10 digits (0 through 9).
- Base: 10
- Digits Used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- Place Values (Powers of 10): \(10^3\) (Thousands), \(10^2\) (Hundreds), \(10^1\) (Tens), \(10^0\) (Units)
2. Binary (Base 2)
The native language of the computer. It uses only two digits, 0 and 1.
- Base: 2
- Digits Used: 0, 1
- Key Terms: A single binary digit is called a bit. Eight bits make a byte.
- Place Values (Powers of 2): \(2^7, 2^6, 2^5, 2^4, 2^3, 2^2, 2^1, 2^0\) (128, 64, 32, 16, 8, 4, 2, 1)
3. Hexadecimal (Base 16)
Hex is used as a compact way to represent long Binary numbers (like colour codes or memory addresses). Since we need 16 different symbols, we use 0-9 and then the letters A-F.
- Base: 16
- Digits Used: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
The Hexadecimal Lookup Table
This table is critical! Make sure you memorize the decimal values for A through F.
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15
Conversion 1: Denary to Binary (Base 10 to Base 2)
We use the repeated division by 2 method. This is the most reliable way to convert Denary numbers into Binary.
Step-by-Step: Converting Denary 149 to Binary
Goal: Convert \(149_{10}\) to Binary.
- Divide the Denary number by 2.
- Record the remainder (it will be 0 or 1).
- Take the whole-number result and repeat the division.
- Continue until the result is 0.
- Read the remainders UPWARDS.
\(149 \div 2 = 74\) Remainder 1
\(74 \div 2 = 37\) Remainder 0
\(37 \div 2 = 18\) Remainder 1
\(18 \div 2 = 9\) Remainder 0
\(9 \div 2 = 4\) Remainder 1
\(4 \div 2 = 2\) Remainder 0
\(2 \div 2 = 1\) Remainder 0
\(1 \div 2 = 0\) Remainder 1
Reading the remainders upwards: 10010101
Key Takeaway for Denary to Binary
Always use repeated division by 2 and remember the golden rule: read the remainders from the bottom to the top to get your final Binary answer.
Conversion 2: Binary to Denary (Base 2 to Base 10)
This conversion is usually easier! We use the place value system, which relies on the powers of 2.
Step-by-Step: Converting Binary 10110011 to Denary
Goal: Convert \(10110011_2\) to Denary.
- Write down the Binary place values (128 down to 1). (Since we have 8 bits, we use 8 positions).
- Write the Binary number directly underneath the place values.
- Add together only the place values that have a '1' underneath them.
Binary Digits: 1 0 1 1 0 0 1 1
Calculation:
\(128 \times 1 = 128\)
\(64 \times 0 = 0\)
\(32 \times 1 = 32\)
\(16 \times 1 = 16\)
\(8 \times 0 = 0\)
\(4 \times 0 = 0\)
\(2 \times 1 = 2\)
\(1 \times 1 = 1\)
Total: \(128 + 32 + 16 + 2 + 1 = 179\)
The Denary number is \(179_{10}\).
Memory Aid for Place Values
Don't worry if this seems tricky at first! Remember the 8-bit place values: 128, 64, 32, 16, 8, 4, 2, 1. They are simply doubling each time as you move left!
Conversion 3 & 4: Binary and Hexadecimal
Converting between Binary and Hex is the easiest because Hexadecimal is simply a shorthand for Binary. Every single Hex digit can represent exactly four Binary bits. These four bits are known as a nybble (or nibble).
A. Binary to Hexadecimal (Base 2 to Base 16)
Step-by-Step: Converting Binary 11010110 to Hex
Goal: Convert \(11010110_2\) to Hex.
- Split the Binary number into groups of four bits (nybbles), starting from the right.
\(1101 \quad 0110\)
- Convert each 4-bit group into its Denary equivalent using the place values 8, 4, 2, 1.
First Nybble (1101): \(8+4+0+1 = 13\)
Second Nybble (0110): \(0+4+2+0 = 6\) - Convert the resulting Denary values into Hexadecimal digits (A-F if necessary).
\(13\) in Hex is D
\(6\) in Hex is 6
The Hexadecimal number is D6.
B. Hexadecimal to Binary (Base 16 to Base 2)
Step-by-Step: Converting Hex 3F to Binary
Goal: Convert \(3F_{16}\) to Binary.
- Take each Hex digit separately. (3 and F)
- Convert each Hex digit into its Denary equivalent. (3 and 15)
- Convert each Denary value into a 4-bit Binary group (a nybble).
Digit 3: Denary 3. Using the 8, 4, 2, 1 places, we need 2 + 1.
\(\rightarrow 0011\)
Digit F: Denary 15. Using the 8, 4, 2, 1 places, we need 8 + 4 + 2 + 1.
\(\rightarrow 1111\)
Combine the groups: \(00111111\)
The Binary number is \(00111111_2\). (Leading zeros are important to keep the 4-bit structure clear!)
Did you know?
Colour codes on websites are often written in Hexadecimal! For example, pure red might be #FF0000. FF represents 255 (the maximum brightness) for the red component. This is much shorter than writing out 24 bits of Binary!
Conversion 5: Denary and Hexadecimal
While it is possible to convert directly (using repeated division by 16), it is generally safer and simpler for GCSE students to convert via Binary. This allows you to practice the skills you just learned!
A. Denary to Hexadecimal (Via Binary)
Step 1: Convert Denary to Binary (using repeated division by 2).
Step 2: Convert the resulting Binary into Hexadecimal (by grouping the bits into nybbles).
- Denary to Binary: \(150_{10} = 10010110_2\)
- Binary to Hex (split into 4s): \(1001 \quad 0110\)
- \(1001 = 9\). \(0110 = 6\).
- Result: \(96_{16}\)
B. Hexadecimal to Denary (Via Binary)
Step 1: Convert Hexadecimal to Binary (by converting each digit to a 4-bit nybble).
Step 2: Convert the resulting Binary into Denary (using the place values 128, 64, 32, etc.).
- Hex to Binary:
A = 1010
5 = 0101
Combined: \(10100101_2\) - Binary to Denary:
\(128+0+32+0+0+4+0+1 = 165\)
- Result: \(165_{10}\)
Quick Review and Common Mistakes
Quick Review: The Conversion Flow
The key is understanding the relationship between the bases:
Binary \(\leftrightarrow\) Hex (Use 4-bit Nybbles)
Common Pitfalls to Avoid
- For Denary to Binary: Forgetting to read the remainders from the bottom to the top.
- For Hex to Binary: Writing a Hex digit (like F=15) as eight bits. Remember, one Hex digit always equals four bits (1111).
- For Binary to Denary: Missing a place value or confusing the value (e.g., mixing up 32 and 16). Always write the 128, 64, 32, 16, 8, 4, 2, 1 line clearly before you start.
You have successfully learned the core of data representation! Practice makes perfect—try converting your age, house number, or favorite number between these three bases. You've got this!