Hex to Decimal & Decimal to Hex Calculator
Convert numbers between hexadecimal (base 16) and decimal (base 10). Switch directions instantly, view exact results, and follow the calculation step by step.
Hex to Decimal
Choose a direction and enter a whole number.
Use digits 0–9 and letters A–F. Optional 0x prefix and − sign.
Try an example
Your result
Calculated in your browser.
FF in base 16 = 255 in base 10.
Calculation steps
- Each hexadecimal digit represents a multiple of a power of 16.
- FF = 15 × 16 + 15 × 1 = 255.
| Hex digit | Place value / calculation | Contribution / remainder |
|---|
Recent conversions
How to use the Hex to Decimal Calculator
Hexadecimal and decimal are two different ways to represent whole numbers. Decimal is the familiar base-10 system used in everyday calculations. Hexadecimal, usually shortened to hex, uses base 16 and appears frequently in programming, digital electronics, memory addresses, and computer color values. This converter handles both directions from one page so you do not need two separate tools.
Choose Hex → Decimal to enter a hexadecimal number such as FF, 2AF, or 0x1A. The tool returns the equivalent decimal integer and explains the positional calculation. Choose Decimal → Hex to enter an ordinary whole number such as 255 or 687. The tool then converts it to hexadecimal by repeated division by 16. Press Reverse to exchange the direction using your last result.
The answer updates while you type. Example buttons provide test values, Copy result saves the converted number to your clipboard where browser permissions allow, and the recent-history chips make it easier to revisit calculations. All arithmetic is performed with JavaScript BigInt, so the tool avoids the rounding errors that affect very large integers when handled as ordinary floating-point numbers.
What is a hexadecimal number?
Hexadecimal uses sixteen symbols rather than ten. The first ten are the digits 0 through 9. Letters A, B, C, D, E, and F stand for decimal values 10, 11, 12, 13, 14, and 15. After hex F comes 10, which represents sixteen in decimal, not ten. After hex 1F comes hex 20, equal to thirty-two in decimal.
Programmers often add 0x before a hex value, such as 0xFF, to distinguish it from a decimal number. This converter accepts both FF and 0xFF. Uppercase and lowercase hex letters have the same value; 2af and 2AF mean exactly the same number. Leading zeros are also permitted in an input but are omitted in the normalized output.
How to convert hex to decimal
Starting at the rightmost digit, multiply each hexadecimal digit by 16 raised to its position. The rightmost position is zero, the next is one, and so on. Add those products to get the decimal answer. This is called positional notation, and it is the same underlying idea used by decimal numbers, except decimal place values are powers of ten.
Worked example: Convert 2AF hex to decimal
Consider hexadecimal 2AF. Read it from right to left: F is 15 in position zero, A is 10 in position one, and 2 is in position two. Calculate 15 × 16⁰ = 15, then 10 × 16¹ = 160, and finally 2 × 16² = 512. Add 512 + 160 + 15 to get 687. Therefore, 2AF in base 16 equals 687 in base 10.
For another quick check, hex FF contains F in both positions: 15 × 16 + 15 × 1 = 255. The conversion table below includes more examples that can be used to verify an answer by hand.
How to convert decimal to hex
To convert a decimal whole number to hexadecimal, divide by 16 and record the remainder. Divide the quotient by 16 again and repeat until the quotient becomes zero. Convert remainders from ten through fifteen into A through F, then read all remainders in reverse order. The first remainder you obtain becomes the rightmost hexadecimal digit.
Worked example: Convert 756 decimal to hex
Divide 756 by 16: the quotient is 47 and the remainder is 4. Next, divide 47 by 16: the quotient is 2 and the remainder is 15, written F in hexadecimal. Finally, divide 2 by 16: the quotient is zero and the remainder is 2. Reading the remainders backward gives 2F4. You can check this result: 2 × 256 + 15 × 16 + 4 = 756.
Decimal zero is a special case only because repeated division stops immediately: the answer is simply hex 0. The tool also supports large numbers and uses exact integer calculations. For lengthy values it displays a shortened list of division steps to keep the page readable, while keeping the final converted number complete.
Hexadecimal to decimal conversion table
This small table provides useful benchmarks. Values in the hex column are base 16 and their partners in the second column are base 10.
| Hexadecimal | Decimal | Common reference |
|---|---|---|
| 0 | 0 | Zero |
| A | 10 | First hex letter |
| F | 15 | Largest single hex digit |
| 10 | 16 | Base-16 rollover |
| 1A | 26 | Two-digit example |
| 64 | 100 | Hundred in decimal |
| 7F | 127 | Seven-bit maximum |
| FF | 255 | Eight-bit maximum |
| 100 | 256 | 16 squared |
| FFF | 4095 | Twelve-bit maximum |
Where are hex numbers used?
Hex notation is shorter than binary because one hexadecimal digit represents four binary bits. A byte with eight bits can be written using only two hex digits, ranging from 00 to FF. That compactness makes hex convenient for inspecting raw data, reading program diagnostics, and representing memory locations. It is a way of writing a number, not a different kind of number.
Hex also appears in CSS color codes. For example, the component FF represents decimal 255, the maximum value of an eight-bit red, green, or blue channel. A six-digit code such as #FF8000 contains three pairs of hexadecimal digits. Color values follow their own formatting rules, so entering the whole color code with a # symbol is not supported by this integer converter.
Negative numbers, leading zeros, and large values
This calculator accepts negative values such as -7B in hex or -123 in decimal. It preserves the minus sign and converts the magnitude, so -7B corresponds to -123. This is a simple signed-number interpretation, not the two’s-complement encoding used for some computer integers. A value such as FF may represent 255 as an unsigned 8-bit value or -1 as a signed 8-bit two’s-complement value, but this tool interprets FF as the unsigned magnitude 255 unless you explicitly supply a minus sign.
Input values can contain up to 256 digits. Long results wrap across lines rather than overflowing the display. For decimal-to-hex conversions, you can choose uppercase or lowercase letters without changing the number’s value. Fractions are not accepted here because this tool is specifically for integers; decimal fractions require a different positional conversion method.
Common hex conversion mistakes
- Treating hex 10 as decimal 10. Hex 10 means sixteen because it has one unit in the sixteens place.
- Forgetting that A–F are digits. A means ten and F means fifteen, not alphabetic labels.
- Reading remainders in the wrong order. When converting decimal to hex by division, start with the final remainder.
- Mixing signed and unsigned meanings. The result here is mathematical integer conversion, not a specified fixed-width computer encoding.
- Entering a non-integer. A decimal such as 12.5 is not a whole number and requires a fractional-base converter.
Frequently asked questions
What is FF in decimal?
FF in hexadecimal is 255 in decimal. Each F represents fifteen, giving 15 × 16 + 15 = 255.
What is 255 in hexadecimal?
Decimal 255 is FF in hexadecimal. Dividing 255 by 16 gives a quotient of 15 and remainder of 15; both become F.
Does 0x change the value of a hex number?
No. It is a common notation prefix. FF and 0xFF represent the same integer in this calculator.
Can I convert negative decimal numbers to hex?
Yes. The calculator displays negative numbers with a leading minus sign. It does not perform fixed-width two’s-complement encoding.
Is there a limit to the size of a number?
The input supports up to 256 digits for usability and performance. The tool uses exact integer arithmetic within that limit rather than rounding large results to floating-point approximations.
Why does decimal to hex sometimes include letters?
Hexadecimal needs sixteen symbols, so A through F represent values ten through fifteen. For example, decimal 26 becomes hex 1A.
Does this calculator store the values I enter?
The conversion logic runs in your browser and maintains a short history only while the page remains open. It does not send your entered numbers to a server. Other services on the website may collect general usage data as explained in its privacy policy.
