Hex to Decimal Converter: How It Works
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator converts a hexadecimal number (base 16) into its decimal equivalent (base 10). You enter a hex value such as 1A3F or FF, and the calculator returns the decimal number, along with a step-by-step breakdown of the conversion. It also shows the intermediate powers of 16 used in the calculation.
Formula
The conversion from hexadecimal to decimal uses the positional notation of base 16. Each digit in a hex number represents a power of 16, starting from the rightmost digit (the least significant) which is 160, then 161, 162, and so on. The formula is:
Decimal = dn-1 × 16n-1 + dn-2 × 16n-2 + … + d1 × 161 + d0 × 160
Where:
- di is the decimal value of the i-th digit (0–9 for digits 0–9, 10 for A, 11 for B, 12 for C, 13 for D, 14 for E, 15 for F).
- n is the total number of digits in the hexadecimal number.
- 16i is the place value for that digit.
Worked Example
Let’s convert the default hex value 1A3F to decimal using the formula above.
- Write the hex digits with their positions: 1 (position 3), A (position 2), 3 (position 1), F (position 0).
- Convert letters to decimal: A = 10, F = 15.
- Compute each term:
- 1 × 163 = 1 × 4096 = 4096
- 10 × 162 = 10 × 256 = 2560
- 3 × 161 = 3 × 16 = 48
- 15 × 160 = 15 × 1 = 15
- Add them: 4096 + 2560 + 48 + 15 = 6719.
The decimal equivalent of 1A3F is 6719, which matches the calculator’s output.
How Hexadecimal Works
Hexadecimal is a base-16 number system that uses sixteen distinct symbols: the digits 0–9 and the letters A–F (where A=10, B=11, C=12, D=13, E=14, F=15). It is widely used in computing because one hex digit represents exactly four binary bits (a nibble). For example, the binary number 1111 is F in hex, and 1010 is A. This makes hex a compact way to express binary values, which is why you see it in memory addresses, color codes (e.g., #FF5733), and machine-level programming.
Converting from hex to decimal is essentially the same process as converting from binary or any other base: multiply each digit by its place value (a power of the base) and sum the results. The only extra step is remembering that letters A–F represent numbers 10–15.
When to Use Hex-to-Decimal Conversion
You might need to convert hex to decimal in several everyday situations:
- Reading memory dumps or debug output – many programming tools display addresses and values in hex, but you may need the decimal equivalent for calculations.
- CSS color codes – a hex color like
#FF0000represents red, but converting the red component (FF) to decimal (255) helps understand the RGB intensity. - MAC addresses and IP addresses – some network settings show hex values; converting them can help with troubleshooting.
- Assembly and low-level programming – when working with registers or bit masks, you often need to switch between hex and decimal.
- Educational exercises – learning number systems is a common topic in computer science courses.
In all these cases, a quick conversion avoids manual calculation errors and saves time.
Common Mistakes and How to Avoid Them
Here are the most frequent pitfalls when converting hex to decimal:
- Forgetting that A–F are 10–15 – A is not 1, it’s 10. Always convert letters before multiplying.
- Misaligning place values – The rightmost digit is 160, not 161. For a 4-digit hex number, the leftmost digit is 163. Double-check the exponent order.
- Using base 10 instead of base 16 – Do not treat a digit like “10� as ten; in hex, “10� is actually 16 in decimal (1×16 + 0).
- Confusing uppercase and lowercase – Hex is case-insensitive, but make sure you don’t mistake the letter “O� for zero or “I� for one.
- Rounding errors in manual calculations – When working with large numbers, a small arithmetic slip can throw off the result. Use a calculator or double-check with an online tool.
Limitations and Precision
This calculator handles non-negative integers. It does not support fractional hex values (like 1A.8) or negative numbers. For fractional hex, you would use negative powers of 16 (16-1, 16-2, etc.), but that is less common in everyday use. Also, the calculator is limited by JavaScript’s number precision; for extremely large hex values (beyond about 16 digits), the decimal result may lose precision. For most practical purposes—such as color codes, memory addresses, and small data values—this is not an issue.
Another limitation is that the calculator expects a valid hex string. If you enter characters outside 0–9 and A–F, the result will be incorrect. The calculator does not validate input, so you should ensure you type a proper hex number.
Alternatives to Manual Conversion
If you don’t have this calculator handy, there are other ways to convert hex to decimal:
- Use a scientific calculator – most have a base conversion mode (DEC, HEX, BIN, OCT).
- Use programming languages – in Python,
int('1A3F', 16)returns 6719; in JavaScript,parseInt('1A3F', 16)does the same. - Use spreadsheet functions – Excel and Google Sheets have
HEX2DEC()functions. - Memorize common conversions – for small values (0–255), you can learn the hex equivalents by heart, which is handy for color codes.
Each method has its own advantages; a dedicated calculator is quick and doesn’t require opening a programming environment.
Frequently Asked Questions
How do I convert hex to decimal manually?
Write the hex digits, assign each a power of 16 starting from the right (16^0), convert any letters (A=10, B=11, etc.), multiply each digit by its power, and sum all results. For example, 2F = 2×16 + 15×1 = 47.
What is the decimal value of the hex number FF?
FF = 15×16 + 15×1 = 255. This is the maximum value you can store in one byte (8 bits).
Why is hex used in computing instead of decimal?
Hex is a compact representation of binary. One hex digit equals four bits, so it’s easy to read and write long binary numbers. For example, the binary 11111111 is FF in hex, which is much shorter and less error-prone.
Can I convert a negative hex number to decimal?
This calculator does not handle negative hex numbers. In computing, negative numbers are often represented in two’s complement, which requires knowing the number of bits. For example, FF could be 255 or -1 depending on context. You need additional information to interpret it correctly.
What is the largest hex number this calculator can handle?
JavaScript’s Number type safely handles integers up to 2^53 – 1, which is about 9 quadrillion. In hex, that’s roughly 13 digits (e.g., 0x1FFFFFFFFFFFFF). Values beyond that may lose precision, but that’s rare for typical uses.
Is there a difference between uppercase and lowercase hex?
No, 1a3f and 1A3F represent the same value. The calculator treats both the same.
Related
Formula used
in h | Hexadecimal value | - | 1A3F | 0 out dec | Decimal value | - | 16^3*1 + 16^2*10 + 16^1*3 + 16^0*15 | 0
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.