Hex to Decimal Converter
To convert hex to decimal, multiply each digit by 16 raised to its position, counting from 0 at the right, and add the results. Letters A–F stand for 10–15. For example, 2AF3 is 2×4096 + 10×256 + 15×16 + 3 = 10995. The converter does this exactly for values of any length.
Widths apply to whole numbers.
Repeats forever:
Repeats forever:
Unsigned:
Method: Sum of powers of 16
| Digit | Value | Weight | Product |
|---|---|---|---|
| 2 | 2 | × 163 | 8192 |
| A | 10 | × 162 | 2560 |
| F | 15 | × 161 | 240 |
| 3 | 3 | × 160 | 3 |
Add the products: 10 995.
How to convert hex to decimal by hand
A hex numeral is a polynomial in 16. Converting hexadecimal to decimal is just evaluating that polynomial, which you can do on paper with nothing harder than multiplication by a few fixed weights.
- Write the hex number and number its digits from the right, starting at 0.
- Replace each letter with its value: A is 10, B 11, C 12, D 13, E 14, F 15.
- Multiply each digit by 16 raised to its position number.
- Add the products; the total is the decimal value.
If you prefer fewer large numbers, there is an equivalent running form: start with the leftmost digit, then for each next digit multiply what you have by 16 and add the digit. For 2AF3 that is 2, then 2 × 16 + 10 = 42, then 42 × 16 + 15 = 687, then 687 × 16 + 3 = 10995. It is the same arithmetic grouped differently, and it is how most parsers do it.
Worked example: 2AF3
Four digits, so the weights run from 16³ down to 16⁰
2AF316 = 10 99510
| Digit | Value | Weight | Product |
|---|---|---|---|
| 2 | 2 | × 163 | 8192 |
| A | 10 | × 162 | 2560 |
| F | 15 | × 161 | 240 |
| 3 | 3 | × 160 | 3 |
Add the products: 10 995.
Powers of 16 worth remembering
Every hex place is worth sixteen of the place to its right. Knowing the first few weights by sight makes a mental estimate quick: a five-digit hex number is somewhere between 65,536 and about a million, and an eight-digit one never exceeds 4,294,967,295.
The weight of each place is also a power of two, four times the position: 16³ is 2¹², which is why 1000 in hex marks a 4 KiB boundary in memory maps and page tables.
| Power | Hex | Decimal |
|---|---|---|
| 160 | 1 | 1 |
| 161 | 10 | 16 |
| 162 | 100 | 256 |
| 163 | 1000 | 4096 |
| 164 | 10000 | 65 536 |
| 165 | 100000 | 1 048 576 |
| 166 | 1000000 | 16 777 216 |
| 167 | 10000000 | 268 435 456 |
| 168 | 100000000 | 4 294 967 296 |
When the same hex means a negative number
The sum of powers gives the unsigned value. A program that stores the bits in a signed 32-bit integer reads the top bit as −2³¹ instead of +2³¹, so patterns from 80000000 up wrap around to negative numbers. 7FFFFFFF is the last positive value; one step past it the sign flips.
To read a value the way a signed type does, pick its width in the converter. The decimal row then shows the signed reading, with the unsigned one underneath. A value from a debugger that looks absurdly large, like 4294967286, is often just −10 seen without a width.
| Hex | Unsigned | Signed 32-bit |
|---|---|---|
| 7FFFFFFF | 2 147 483 647 | 2 147 483 647 |
| 80000000 | 2 147 483 648 | −2 147 483 648 |
| FFFFFFF6 | 4 294 967 286 | −10 |
| FFFFFFFF | 4 294 967 295 | −1 |
Questions people ask
What is FFFFFFFF in decimal?
4294967295 as an unsigned number, which is 2³² − 1. Read as a signed 32-bit integer in two’s complement, the same bits mean −1.
What is 7FFFFFFF in decimal?
2147483647, which is 2³¹ − 1, the largest signed 32-bit integer (INT32_MAX in C). One more, 80000000, reads as −2147483648 when treated as signed 32-bit.
What is 12 hex in decimal?
18. The 1 sits in the sixteens place and the 2 in the ones place, so 1 × 16 + 2 = 18.
What is 100 hex in decimal?
256, because 100 in hex is 1 × 16² = 256. It is one more than FF (255), the largest value of a byte.
How do I convert a hex fraction like 1A.8 to decimal?
Digits after the point use negative powers of 16. In 1A.8 the 8 is worth 8 × 16⁻¹ = 0.5, so 1A.8 = 1 × 16 + 10 + 0.5 = 26.5.
Related conversions
Last updated