How to convert hexadecimal to decimal
Multiply each digit by 16 raised to the power of its position (counting from 0 on the right), then add the results.
Worked example: convert hexadecimal 7E9 to decimal.
| Digit | Position weight | Digit × weight |
|---|---|---|
| 7 | 162 | 1792 |
| E | 161 | 224 |
| 9 | 160 | 9 |
Adding the last column gives 2025.
Type any hexadecimal number in the converter above and open Show the working to see these steps for your own value.
Hex digits in decimal and binary
| Hex | Decimal | Binary | Hex | Decimal | Binary |
|---|---|---|---|---|---|
| 0 | 0 | 0000 | 8 | 8 | 1000 |
| 1 | 1 | 0001 | 9 | 9 | 1001 |
| 2 | 2 | 0010 | A | 10 | 1010 |
| 3 | 3 | 0011 | B | 11 | 1011 |
| 4 | 4 | 0100 | C | 12 | 1100 |
| 5 | 5 | 0101 | D | 13 | 1101 |
| 6 | 6 | 0110 | E | 14 | 1110 |
| 7 | 7 | 0111 | F | 15 | 1111 |
Convert hexadecimal to decimal in Excel and code
| Where | Formula | Result |
|---|---|---|
| Excel / Google Sheets | =HEX2DEC("7E9") | 2025 |
| Python | int("7E9", 16) | 2025 |
| JavaScript | parseInt("7E9", 16).toString(10) | 2025 |
Quick reference
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 31 | 11111 | 37 | 1F |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1000 | 1111101000 | 1750 | 3E8 |
| 1024 | 10000000000 | 2000 | 400 |
Negative numbers and two's complement
On paper, a negative number just gets a minus sign: −45 is −101101 in binary. Computers store whole numbers in a fixed
number of bits using two's complement: invert every bit of the positive value and add 1. In 8 bits,
45 is 00101101, so −45 is 11010011 (hex D3). Enter a negative whole number above
to see its 8, 16, 32 and 64-bit forms.
Where you'll see these number systems
- Binary: how computers store everything; bit masks, flags and network subnet masks.
- Octal: Unix and Linux file permissions such as
chmod 755. - Decimal: everyday counting, and how most programs display numbers.
- Hexadecimal: colour codes (
#FF5733), memory addresses, MAC addresses, Unicode code points and hashes. One hex digit is exactly 4 bits, so two digits make a byte.