What is the Hexadecimal Number System?
The hexadecimal number system (often abbreviated as "hex") functions identically to the familiar decimal and binary systems, but instead of using a base of 10 or 2, it uses a base of 16. The system comprises 16 distinct symbols. It uses the standard numerals 0 through 9, just like the decimal system, but introduces the letters A, B, C, D, E, and F to represent the values 10 through 15.
In computing and digital electronics, hex is incredibly useful because each hexadecimal digit represents exactly four binary digits (called a nibble). This means a large, unwieldy binary number like 1010101010 can be easily compressed and written as 2AA in hex. This simplifies reading, writing, and understanding binary code for programmers and systems analysts.
Typical Conversions Reference Table
| Hexadecimal | Binary | Decimal |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 2 | 10 | 2 |
| 3 | 11 | 3 |
| 4 | 100 | 4 |
| 5 | 101 | 5 |
| 6 | 110 | 6 |
| 7 | 111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| A | 1010 | 10 |
| B | 1011 | 11 |
| C | 1100 | 12 |
| D | 1101 | 13 |
| E | 1110 | 14 |
| F | 1111 | 15 |
| 14 | 10100 | 20 |
| 3F | 111111 | 63 |
How to Convert Hexadecimal to Decimal
Converting between decimal and hex involves understanding the place values of the different number systems. In the hex system, each place value represents a power of 16 (160, 161, 162, etc.), moving from right to left.
Example: Convert Hex 2AA to Decimal.
2AA = (2 × 162) + (A × 161) + (A × 160)
2AA = (2 × 256) + (10 × 16) + (10 × 1)
2AA = 512 + 160 + 10 = 682
How to Convert Decimal to Hexadecimal
Converting from decimal back to hex uses the same core concepts in reverse. You determine how many times the largest power of 16 fits into your starting number, find the remainder, and repeat the process for lower powers of 16.
- Find the largest power of 16 that is less than or equal to the decimal number (X).
- Determine how many times that power of 16 goes into X. This is your first hex digit.
- Subtract that product from X to find the remainder (Y).
- Repeat steps 1-3 using the remainder Y until you reach the 160 (ones) place.
- Assign the corresponding letters A-F for any quotients between 10 and 15.
1) Largest power = 162 = 256.
2) 256 × 5 = 1280. First digit is 5.
3) Remainder = 1500 - 1280 = 220.
4) Next power = 161 = 16. 16 × 13 = 208. Digit is 13 (which is 'D' in hex).
5) Remainder = 220 - 208 = 12.
6) 16 is larger than 12, so 12 goes in the ones column (which is 'C' in hex).
Result: 5DC
Hexadecimal Arithmetic: Addition & Subtraction
Hex Addition
Hex addition works exactly like decimal addition, with the only difference being the symbols A-F. When the sum of a column exceeds 15, you subtract 16, leave the remainder in the current column, and carry the 1 over to the next column.
Example: Add 8AB + B78
- Right column: B (11) + 8 = 19. 19 is 16 + 3. Write 3, carry 1.
- Middle column: A (10) + 7 + 1 (carried) = 18. 18 is 16 + 2. Write 2, carry 1.
- Left column: 8 + B (11) + 1 (carried) = 20. 20 is 16 + 4. Write 4, carry 1.
- Final Result:
1423
Hex Subtraction
Subtraction is calculated similarly. The primary difference is borrowing. When borrowing in hex, the "1" you borrow from the adjacent column represents 16 (in decimal), not 10. You add 16 to the number you are subtracting from.
Example: Subtract 5DC - 3AF
- Right column: C (12) is smaller than F (15). Borrow 1 from D (becomes C). Add 16 to 12 = 28. 28 - 15 = 13 (D).
- Middle column: C (12) - A (10) = 2.
- Left column: 5 - 3 = 2.
- Final Result:
22D
Frequently Asked Questions
The standard numerical digits only go from 0 to 9, which provides 10 symbols. Because the hexadecimal system has a base of 16, it needs 16 distinct symbols to represent values in a single column before carrying over. To fill the gap between 10 and 15 without confusing them for two-digit decimal numbers, the first six letters of the alphabet (A, B, C, D, E, F) were universally adopted.
A nibble is a four-bit aggregation, or half of an eight-bit byte. Since four binary digits can create 16 different combinations (from 0000 to 1111), a single hexadecimal digit corresponds perfectly to one nibble. This is why hex is so commonly used to represent binary code in computing.
No, hexadecimal is not generally case-sensitive. The characters 1A3F mean the exact same thing as 1a3f. Most calculators, including this one, will format the output in uppercase for better readability, but will accept input in either case.
Long division and multiplication in hex are identical to the decimal process, but all multiplication and subtraction occur in base-16. Because keeping track of hex multiplication tables (e.g., C × E = A8) can be difficult, it is highly recommended to use an automated calculator, or to manually convert the hex values to decimal, perform the math, and convert the final answer back to hex.
In many programming languages like C, C++, Java, and Python, the prefix 0x is used to denote that the following numbers are formatted in hexadecimal. Without the prefix, the compiler might assume a number like 100 is decimal, when the programmer intended for it to be the hex equivalent of 256.