Understanding Hexadecimal
Hexadecimal (often called "hex") is a base-16 number system that uses sixteen digits: 0-9 and A-F (where A=10, B=11, C=12, D=13, E=14, F=15). It's widely used in computing because it provides a compact, human-readable way to represent binary data.
Hexadecimal is a positional number system, just like decimal. But instead of each position representing a power of 10 (1, 10, 100, 1000...), each position represents a power of 16 (1, 16, 256, 4096...). The rightmost position is 16⁰ (1), next is 16¹ (16), then 16² (256), then 16³ (4096), and so on.
Hexadecimal position values: ... 4096 256 16 1
To convert hexadecimal to decimal, you multiply each digit by its position value and add up the results. For digits A-F, you first convert them to their decimal equivalents (10-15).
Step-by-Step Conversion Method
Here's exactly how to convert hexadecimal to decimal using the positional value method:
- Write down the hexadecimal number - For example, 2A7
- Convert any letters to numbers - A=10, B=11, C=12, D=13, E=14, F=15
- Number the positions from right to left - Start with 0 on the right
- Multiply each digit by 16 raised to its position - Use 16⁰, 16¹, 16², etc.
- Add up all the results - The sum is the decimal equivalent
Complete example: Convert 2A7 to decimal
Step 1: Hexadecimal number - 2A7
Step 2: Convert letters - A = 10
Step 3: Number the positions
Digits: 2 A 7
Position: 2 1 0 (from right to left)
Step 4: Multiply each digit
Position 0: 7 × 16⁰ = 7 × 1 = 7
Position 1: 10 × 16¹ = 10 × 16 = 160
Position 2: 2 × 16² = 2 × 256 = 512
Step 5: Add them up
7 + 160 + 512 = 679
Result: 2A7 in hexadecimal = 679 in decimal
Our converter shows you these steps for any hexadecimal number you enter, including the conversion of letters A-F to numbers 10-15.
Hexadecimal Digit Values
Here's the complete hexadecimal digit system:
| Hexadecimal | Decimal Value | Binary (4-bit) |
|---|---|---|
| 0 | 0 | 0000 |
| 1 | 1 | 0001 |
| 2 | 2 | 0010 |
| 3 | 3 | 0011 |
| 4 | 4 | 0100 |
| 5 | 5 | 0101 |
| 6 | 6 | 0110 |
| 7 | 7 | 0111 |
| 8 | 8 | 1000 |
| 9 | 9 | 1001 |
| A | 10 | 1010 |
| B | 11 | 1011 |
| C | 12 | 1100 |
| D | 13 | 1101 |
| E | 14 | 1110 |
| F | 15 | 1111 |
Notice that each hexadecimal digit corresponds to exactly four binary digits. This makes hex-to-binary and binary-to-hex conversions very straightforward.
Common Hexadecimal to Decimal Conversions
Here are important hexadecimal numbers and their decimal equivalents:
| Hexadecimal | Decimal | What It Represents |
|---|---|---|
| 0 | 0 | Zero |
| 1 | 1 | One |
| A | 10 | Ten (first letter) |
| F | 15 | Fifteen (largest single hex digit) |
| 10 | 16 | Sixteen (first "carry" in hex) |
| FF | 255 | Maximum 8-bit value |
| 100 | 256 | 256 (16²) |
| FFF | 4095 | Maximum 12-bit value |
| 1000 | 4096 | 4096 (16³) |
| FFFF | 65535 | Maximum 16-bit value |
| FFFFFF | 16777215 | Maximum 24-bit value |
| DEADBEEF | 3735928559 | Famous debug value ("dead beef") |
Try converting these hexadecimal numbers using our converter to practice!
Hexadecimal in Web Colors
One of the most common uses of hexadecimal is in web color codes. Colors on the web are specified using a # followed by six hexadecimal digits representing red, green, and blue components:
Understanding web color codes
Format: #RRGGBB
RR = Red component (00 to FF, or 0 to 255 in decimal)
GG = Green component (00 to FF, or 0 to 255 in decimal)
BB = Blue component (00 to FF, or 0 to 255 in decimal)
Example: #FF8800 = 255 red, 136 green, 0 blue = Orange
| Color | Hexadecimal | Decimal (R,G,B) |
|---|---|---|
| Red | #FF0000 | 255, 0, 0 |
| Green | #00FF00 | 0, 255, 0 |
| Blue | #0000FF | 0, 0, 255 |
| Yellow | #FFFF00 | 255, 255, 0 |
| White | #FFFFFF | 255, 255, 255 |
| Black | #000000 | 0, 0, 0 |
Hexadecimal in Programming
Programmers use hexadecimal extensively because:
- Memory Addresses - Computer memory locations are shown in hexadecimal
- Debugging - Debuggers show data in hexadecimal (hex dumps)
- Bit Masks - Hex makes it easy to work with specific bits (each hex digit = 4 bits)
- Constants - Programmers use hex for constants (0xFF for 255)
- Assembly Language - Low-level programming uses hex extensively
- Error Codes - Some error messages use hexadecimal codes
Hexadecimal in different programming languages
C/C++/Java/JavaScript: 0x prefix (0xFF = 255)
Python: 0x prefix (0xFF = 255)
HTML/CSS: # prefix for colors (#FF0000 = red)
Assembly: Often uses h suffix or 0x prefix