Hexadecimal and Octal
Why This Matters
# Hexadecimal and Octal - Cambridge A-Level Computer Science ## Summary This lesson covers alternative number systems used extensively in computing: hexadecimal (base-16) and octal (base-8). Students learn to convert between binary, denary, hexadecimal and octal systems, understanding that hexadecimal provides a more compact representation of binary data (4 bits per hex digit), making it particularly useful for representing memory addresses, colour codes, and machine code. The topic is essential for A-Level examinations, with typical questions requiring conversions, explaining advantages of hexadecimal over binary, and applying these systems to practical contexts such as MAC addresses, IPv6 addresses, and assembly language debugging. ## Exam Relevance Expect 4-6 mark questions on conversions and 2-3 mark questions explaining why hexadecimal is preferred in specific computing applications.
Key Words to Know
Core Concepts & Theory
Hexadecimal (base-16) and octal (base-8) are number systems used extensively in computing as shorthand for binary. Understanding these systems is fundamental for A-Level Computer Science.
Hexadecimal System: Uses 16 digits (0-9, A-F where A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit represents exactly 4 binary bits, making conversions efficient. The place values are powers of 16: ..., 16³, 16², 16¹, 16⁰ (4096, 256, 16, 1).
Octal System: Uses 8 digits (0-7). Each octal digit represents exactly 3 binary bits. Place values are powers of 8: ..., 8³, 8², 8¹, 8⁰ (512, 64, 8, 1).
Key Conversion Formulas:
- Binary to Hex: Group bits in fours from right, convert each group
- Binary to Octal: Group bits in threes from right, convert each group
- Denary to Hex/Octal: Use repeated division by 16 or 8, recording remainders
Mnemonic for Hex digits: "All Bad Children Deserve Extra Food" (A=10, B=11, C=12, D=13, E=14, F=15)
Cambridge Definition: Hexadecimal is a base-16 numbering system particularly useful for representing large binary numbers concisely, commonly used in memory addresses, colour codes, and machine code.
Why use these systems? Binary numbers become unwieldy (11010011101 is difficult to read). The hex equivalent (6DD) is far more manageable. Since 16=2⁴ and 8=2³, conversions between binary and hex/octal are straightforward, unlike denary conversions which require complex arithmetic.
Detailed Explanation with Real-World Examples
Real-World Applications demonstrate why hexadecimal and octal remain relevant despite appearing archaic:
1. Memory Addresses: Computer memory locations are expressed in hexadecimal. A typical address like 0x7FFF5C28 is far more readable than its 32-bit binary equivalent. Programmers debugging code constantly reference hex addresses.
2. Colour Codes: Web designers use hex colour codes (#FF5733). Here, FF=255 (red intensity), 57=87 (green), 33=51 (blue). This RGB system makes 16.7 million colours accessible through compact 6-character codes.
3. MAC Addresses: Network cards have unique identifiers like A4:5E:60:E8:3B:9F. Each pair is a hex byte (00-FF), making 48 bits manageable.
4. File Permissions (Octal): Unix/Linux systems use octal for file permissions. The command chmod 755 sets specific read/write/execute permissions, where each digit (7,5,5) represents a 3-bit pattern.
Analogy: Think of hex as shorthand notation for binary, like abbreviations in texting. "LOL" is easier than "laughing out loud", just as "3F" is simpler than "00111111". The meaning stays identical, but communication improves.
Historical Context: Octal was popular in early computing (PDP-8 computers) because word sizes were multiples of 3 bits. Modern systems favour hex due to 8-bit bytes (2 hex digits perfectly represent 1 byte).
Industry Practice: Assembly language programmers and cybersecurity professionals use hex daily when examining memory dumps, analysing malware, or reverse-engineering software.
Worked Examples & Step-by-Step Solutions
Example 1: Convert binary 101110110011 to hexadecimal
Solution:
- Group from right in fours: 1011 1011 0011
- Convert each group: 1011₂=11₁₀=B₁₆, 1011₂=B₁₆, 0011₂=3₁₆
- Answer: BB3₁₆
Examiner note: Always group from RIGHT. Adding leading zeros if needed (e.g., 0101) earns marks.
Example 2: Convert 3A7₁₆ to denary
Solution:
- Identify place values: 3×16² + A×16¹ + 7×16⁰
- Substitute A=10: 3×256 + 10×16 + 7×1
- Calculate: 768 + 160 + 7
- Answer: 935₁₀
Examiner note: Show ALL working. Converting hex letters to denary first prevents errors.
Example 3: Convert octal 657₈ to binary then hexadecimal
Solution:
- Convert each octal digit to 3 bits:
- 6₈ = 110₂
- 5₈ = 101₂
- 7₈ = 111₂
- Binary result: 110101111₂
- Group in fours from right: 0001 1010 1111
- Convert to hex: 1₁₆, A₁₆, F₁₆
- Answer: 1AF₁₆
Examiner note: Two-step conversions (via binary) are safer than direct octal↔hex conversion, which risks arithmetic errors worth lost marks.
Common Exam Mistakes & How to Avoid Them
Mistake 1: Grouping binary from the LEFT instead of RIGHT Why it happens: Students read left-to-right naturally H...
Cambridge Exam Technique & Mark Scheme Tips
Command Word Mastery:
- "Convert": Show all working steps. Even if your answer is wrong, correct method earns pa...
2 more sections locked
Upgrade to Starter to unlock all study notes, audio listening, and more.
Exam Tips
- 1.**Memorise Hex Equivalents:** Be able to quickly recall the decimal and 4-bit binary equivalents for hex digits A-F (e.g., F = 15 = 1111). This speeds up conversions significantly.
- 2.**Practice Grouping:** For binary to hex/octal conversions, always group from the **right-hand side** first and pad with leading zeros on the left if necessary. Errors often occur when grouping from the left.
- 3.**Show Your Working:** For multi-step conversions (e.g., Hex to Decimal, or Decimal to Binary/Hex/Octal), clearly show your division/multiplication steps and remainders. This helps earn partial credit even if the final answer is incorrect.