The Hexadecimal Number System

Hexadecimal number system is a base-16 number system used in computer programming and microprocessor operations. It uses 16 symbols: digits 0-9 and letters A-F, where A=10, B=11, C=12, D=13, E=14, and F=15.

Quick Summary

  • Hexadecimal is a base-16 number system widely used in computing
  • Uses 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
  • Helps represent large binary numbers in shorter form
  • Commonly used for memory addresses, color codes, and MAC addresses
  • Each hexadecimal digit equals four binary digits (bits)

What is the Hexadecimal Number System?

The hexadecimal number system (often called “hex” for short) is a way of counting and representing numbers using base 16 instead of base 10 like we use in everyday life. While we normally count from 0 to 9 before moving to the next place value, hexadecimal counts from 0 to 15 before moving up.

But wait – we don’t have single digits for numbers 10 through 15! That’s where letters come in. Computer scientists decided to use the letters A through F to represent these values:

Hexadecimal Decimal Value
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
A 10
B 11
C 12
D 13
E 14
F 15

Why Do Computers Use Hexadecimal?

Computers work with binary (base-2), which only uses 0s and 1s. While binary is perfect for machines, it’s hard for humans to read. For example, the binary number 11111010110 is difficult to remember and easy to make mistakes with.

Hexadecimal solves this problem. Each hex digit represents exactly four binary digits. This makes it much easier for programmers to work with computer data. The same binary number (11111010110) becomes FAB in hexadecimal – much shorter and easier to remember!

Real-World Uses of Hexadecimal in Nigeria

You’ve probably seen hexadecimal numbers without realizing it:

1. Color codes on websites: When designing websites, colors are written in hex. For example, #FF0000 is red, #00FF00 is green, and #0000FF is blue. Nigerian web designers use these codes every day.

2. MAC addresses: Every phone, laptop, or computer has a unique MAC address written in hexadecimal, like 00:1A:2B:3C:4D:5E. When you connect to MTN, Airtel, or Glo networks, your device uses this address.

3. Error codes: When your computer shows an error message, you might see codes like “Error 0x80070005” – that “0x” tells you it’s a hexadecimal number.

4. Memory addresses: Computer programmers use hex to talk about where data is stored in RAM.

Converting Between Number Systems

Decimal to Hexadecimal

To convert a decimal number to hexadecimal, divide by 16 repeatedly and note the remainders.

Example: Convert 156 (decimal) to hexadecimal

  • 156 ÷ 16 = 9 remainder 12 (which is C in hex)
  • 9 ÷ 16 = 0 remainder 9
  • Reading from bottom to top: 156 in decimal = 9C in hexadecimal

Hexadecimal to Decimal

To convert hex to decimal, multiply each digit by 16 raised to its position power (starting from 0 on the right).

Example: Convert 2A5 (hexadecimal) to decimal

  • 2 × 16² = 2 × 256 = 512
  • A × 16¹ = 10 × 16 = 160 (remember A = 10)
  • 5 × 16⁰ = 5 × 1 = 5
  • Add them up: 512 + 160 + 5 = 677

Binary to Hexadecimal

This is the easiest conversion! Group the binary digits in sets of four (starting from the right), then convert each group.

Example: Convert 110110101111 (binary) to hexadecimal

  • Group into fours: 1101 1010 1111
  • 1101 = 13 = D in hex
  • 1010 = 10 = A in hex
  • 1111 = 15 = F in hex
  • Answer: DAF

Comparison of Number Systems

Decimal (Base-10) Binary (Base-2) Hexadecimal (Base-16)
0 0000 0
1 0001 1
5 0101 5
10 1010 A
15 1111 F
16 10000 10
255 11111111 FF

Common Exam Mistakes (WAEC Chief Examiner Reports)

Students often make these errors in WAEC and NECO exams:

  • Confusing letters and numbers: Forgetting that A=10, not 1. When you see ‘A’ in hexadecimal, it means 10, not the letter A.
  • Wrong grouping in binary conversion: Students group binary digits in threes instead of fours when converting to hex. Always use groups of four!
  • Calculation errors: Making mistakes with powers of 16 (16⁰=1, 16¹=16, 16²=256). Write these out clearly in exams.
  • Forgetting the base: Not showing which number system you’re using. Always indicate if your answer is in hex (use subscript ₁₆ or write “hex”).
  • Poor working: Not showing steps clearly. WAEC examiners say “merely writing the answer without showing working attracts no marks.”

Practice Questions

Multiple Choice Questions

1. The hexadecimal number system has a base of:

  • a) 2
  • b) 8
  • c) 10
  • d) 16 ✓

2. What is the decimal equivalent of hexadecimal C?

  • a) 10
  • b) 11
  • c) 12 ✓
  • d) 13

3. The binary number 1111 is equal to which hexadecimal digit?

  • a) D
  • b) E
  • c) F ✓
  • d) 10

4. Which of the following is NOT a valid hexadecimal number?

  • a) 9AB
  • b) FFF
  • c) 1G4 ✓
  • d) A0C

Theory Questions

1. (a) Define hexadecimal number system. (2 marks)
(b) State three uses of hexadecimal numbers in computing. (3 marks)
(c) Convert the hexadecimal number 3F to decimal. Show all working. (5 marks)

Exam tip: For part (c), write each step clearly. Show 3 × 16¹ and F × 16⁰ separately before adding.

2. (a) Convert the binary number 101101 to hexadecimal. (4 marks)
(b) Explain why programmers prefer hexadecimal to binary when writing code. (3 marks)

Exam tip: For part (a), remember to group the binary number in fours from the right. Add zeros on the left if needed.

3. The hexadecimal representation of a color code is #FF5733.

  • (a) How many hexadecimal digits are in this code? (1 mark)
  • (b) What is the decimal value of the first pair (FF)? (3 marks)
  • (c) State one advantage of using hexadecimal for color codes. (2 marks)

Memory Aids

Remember the hex letters: “All Bad Children Deserve Education From teachers” = A B C D E F

Remember hex values:

  • A = 10 (A is 1st letter, 10 is 1st two-digit number)
  • F = 15 (F is 6th letter, count from A: A=10, B=11, C=12, D=13, E=14, F=15)

Binary to hex trick: “Four Friends” = group in 4s when converting binary to hex

Powers of 16:

  • 16⁰ = 1 (anything to power 0 is 1)
  • 16¹ = 16 (anything to power 1 is itself)
  • 16² = 256 (16 × 16)
  • 16³ = 4096 (16 × 16 × 16)

Related Topics

  • Binary number system
  • Octal number system
  • Number system conversions
  • Computer memory and addressing
  • Data representation in computers

Leave a comment

not allowed!