In the world of computers and digital electronics, numbers are often represented in different systems to make processing and understanding easier. One such important system is the hexadecimal number system, often called simply "hex".
The hexadecimal system is a base-16 number system. This means it uses 16 unique symbols to represent values. Unlike the decimal system (base-10), which uses digits 0 through 9, hexadecimal uses digits 0 to 9 and then the letters A to F to represent values from 10 to 15.
Why is hexadecimal important? Because it provides a compact and human-friendly way to represent binary numbers (base-2), which computers use internally. Hexadecimal numbers are shorter and easier to read than long strings of binary digits, making them very useful in programming, memory addressing, and digital color codes.
Let's understand the basics of the hexadecimal system:
| Hex Digit | 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 |
For example, the hex number 1F means:
\(1 \times 16^1 + 15 \times 16^0 = 16 + 15 = 31\) in decimal.
Understanding how to convert between hexadecimal and decimal is crucial. Let's look at both directions.
graph TD A[Start] --> B{Convert Hex to Decimal?} B -- Yes --> C[Identify each hex digit and its decimal value] C --> D[Multiply each digit by 16 raised to its position power] D --> E[Sum all the values] E --> F[Decimal number obtained] B -- No --> G{Convert Decimal to Hex?} G -- Yes --> H[Divide decimal number by 16] H --> I[Record remainder as hex digit] I --> J[Divide quotient by 16 again] J --> K{Quotient zero?} K -- No --> I K -- Yes --> L[Write remainders in reverse order] L --> M[Hexadecimal number obtained]Hexadecimal to Decimal: Multiply each hex digit by \(16^i\) where \(i\) is the position index from right (starting at 0), then add all results.
Decimal to Hexadecimal: Divide the decimal number repeatedly by 16, noting the remainder each time. The hex number is the remainders read from last to first.
Because 16 is a power of 2 (specifically \(16 = 2^4\)), each hex digit corresponds exactly to 4 binary bits. This makes conversion between hex and binary straightforward and fast.
| Hex Digit | Binary Equivalent (4 bits) |
|---|---|
| 0 | 0000 |
| 1 | 0001 |
| 2 | 0010 |
| 3 | 0011 |
| 4 | 0100 |
| 5 | 0101 |
| 6 | 0110 |
| 7 | 0111 |
| 8 | 1000 |
| 9 | 1001 |
| A | 1010 |
| B | 1011 |
| C | 1100 |
| D | 1101 |
| E | 1110 |
| F | 1111 |
To convert a hex number to binary, replace each hex digit with its 4-bit binary equivalent. To convert binary to hex, group binary digits in sets of 4 (starting from the right), then convert each group to its hex digit.
2F to its decimal equivalent. Step 1: Identify each digit and its decimal value.
2 = 2, F = 15
Step 2: Multiply each digit by 16 raised to its position (rightmost digit is position 0).
\(2 \times 16^1 = 2 \times 16 = 32\)
\(15 \times 16^0 = 15 \times 1 = 15\)
Step 3: Add the results.
\(32 + 15 = 47\)
Answer: Hexadecimal 2F equals decimal 47.
Step 1: Divide 255 by 16.
255 / 16 = 15 remainder 15
Step 2: Divide quotient 15 by 16.
15 / 16 = 0 remainder 15
Step 3: Write remainders in reverse order.
Remainders: 15 (F), 15 (F)
Answer: Decimal 255 equals hexadecimal FF.
1A3 to binary. Step 1: Convert each hex digit to 4-bit binary using the table.
Step 2: Combine the binary groups.
0001 1010 0011
Answer: Hexadecimal 1A3 equals binary 000110100011.
3B and 4F. Step 1: Convert hex digits to decimal for addition.
3B: 3 = 3, B = 11
4F: 4 = 4, F = 15
Step 2: Add the rightmost digits (units place): 11 + 15 = 26.
Since 26 > 15, subtract 16: 26 - 16 = 10 (which is A in hex), carry over 1 to next digit.
Step 3: Add left digits plus carry: 3 + 4 + 1 = 8.
Step 4: Combine results: left digit 8, right digit A.
Answer: 3B + 4F = 8A in hexadecimal.
2A from 7E in hexadecimal. Step 1: Convert digits to decimal.
7E: 7 = 7, E = 14
2A: 2 = 2, A = 10
Step 2: Subtract rightmost digits: 14 - 10 = 4.
Step 3: Subtract left digits: 7 - 2 = 5.
Step 4: Combine results: 5 (left), 4 (right).
Answer: 7E - 2A = 54 in hexadecimal.
When to use: When converting between hex and decimal or performing arithmetic.
When to use: For fast conversion between hex and binary without lengthy calculations.
When to use: To simplify conversions and understand data representation in computers.
When to use: When converting decimal numbers to hexadecimal.
When to use: When performing addition or subtraction in hexadecimal.
Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.
Go to practice →