Skip to main content

πŸ”’ Hexadecimal Conversion

πŸ”’ Working with Hexadecimal Numbers

Hexadecimal (base-16) is a number system commonly used in computing as a more human-friendly way to represent binary data. Understanding hexadecimal and how to convert between number systems is an essential skill in information technology.

πŸ” Hexadecimal Number System​

What is Hexadecimal?​

  • A base-16 number system
  • Uses 16 digits: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15)
  • Position values are powers of 16 (16^0, 16^1, 16^2, etc.)
  • Often prefixed with "0x" or suffixed with "h" to indicate hexadecimal

πŸ€” Why Hexadecimal is Used​

  • Compact representation of binary data
  • One hexadecimal digit represents exactly 4 binary digits (bits)
  • Easier for humans to read and write than long binary sequences
  • Commonly used for memory addresses, color codes, and machine code

πŸ”„ Hexadecimal to Denary Conversion​

To convert hexadecimal to denary (base-10):

  1. Identify the position value of each digit (powers of 16 from right to left)
  2. Convert each hexadecimal digit to its denary value
  3. Multiply each digit value by its position value
  4. Sum all the results

Example 1: Convert 2F₁₆ to denary​

2    F
↓ ↓
16^1 16^0
16 1
↓ ↓
2Γ—16 15Γ—1
32 15

Sum: 32 + 15 = 47₁₀

Example 2: Convert 1A3₁₆ to denary​

1    A    3
↓ ↓ ↓
16^2 16^1 16^0
256 16 1
↓ ↓ ↓
1Γ—256 10Γ—16 3Γ—1
256 160 3

Sum: 256 + 160 + 3 = 419₁₀

πŸ”„ Denary to Hexadecimal Conversion​

To convert denary to hexadecimal:

  1. Divide the number by 16
  2. Record the remainder (0-15, using A-F for 10-15)
  3. Continue dividing the quotient by 16 until the quotient becomes 0
  4. Read the remainders from bottom to top to get the hexadecimal number

Example 1: Convert 250₁₀ to hexadecimal​

Division    Quotient    Remainder
250 Γ· 16 15 10 (A)
15 Γ· 16 0 15 (F)

Reading remainders from bottom to top: FA₁₆

Example 2: Convert 52₁₀ to hexadecimal​

Division    Quotient    Remainder
52 Γ· 16 3 4
3 Γ· 16 0 3

Reading remainders from bottom to top: 34₁₆

πŸ”€ Binary to Hexadecimal Conversion​

To convert binary to hexadecimal:

  1. Group the binary digits in sets of 4, starting from the right
  2. Convert each group of 4 bits to its hexadecimal equivalent
  3. Combine the hexadecimal digits

Example 1: Convert 1010 1101β‚‚ to hexadecimal​

1010  1101
↓ ↓
A D

Result: AD₁₆

Example 2: Convert 11 1110 0001β‚‚ to hexadecimal​

0011  1110  0001
↓ ↓ ↓
3 E 1

Result: 3E1₁₆

πŸ”€ Hexadecimal to Binary Conversion​

To convert hexadecimal to binary:

  1. Convert each hexadecimal digit to its 4-bit binary equivalent
  2. Combine all binary groups

Example 1: Convert C5₁₆ to binary​

C    5
↓ ↓
1100 0101

Result: 1100 0101β‚‚

Example 2: Convert 2FA₁₆ to binary​

2     F     A
↓ ↓ ↓
0010 1111 1010

Result: 0010 1111 1010β‚‚

πŸ“ Common Hexadecimal Values to Remember​

HexBinaryDenaryHexBinaryDenary
000000810008
100011910019
200102A101010
300113B101111
401004C110012
501015D110113
601106E111014
701117F111115

πŸ’» Practical Applications​

Hexadecimal is commonly used in:

  • 🧠 Memory addresses in programming and debugging
  • 🎨 Color codes in web design (e.g., #FF0000 for red)
  • 🌐 MAC addresses for network interfaces
  • πŸ” File signatures and hexadecimal editors
  • πŸ–₯️ Assembly language and machine code representation

Understanding hexadecimal conversion is essential for many aspects of computer science and digital systems work.