How to use the hex to decimal converter
- Type or paste your hexadecimal value into the input field. Prefixes like
0xor#are stripped automatically. - Choose a signed two's complement bit width if you need negative interpretation, or leave it as None for unsigned.
- Read the decimal result along with the binary, octal and byte count below the input. Decimal is shown without thousands separators so you can copy it into code.
How hex to decimal conversion works
Hexadecimal is base 16, using digits 0 through 9 and letters A through F. To convert hex to decimal, multiply each digit by 16 raised to the power of its position index, counting from right to left starting at zero.
For example, the hex value 1A3F converts as follows:
1 x 163 + A x 162 + 3 x 161 + F x 160
= 1 x 4096 + 10 x 256 + 3 x 16 + 15 x 1
= 4096 + 2560 + 48 + 15 = 6719
This hex to decimal converter uses JavaScript BigInt internally, so it can handle values far beyond the standard 53-bit integer limit without losing precision.
Signed two's complement explained
In unsigned representation every bit contributes a positive value. In signed two's complement, the most significant bit acts as a sign indicator. If that bit is 1, the number is negative.
To find the decimal value of a negative two's complement number, invert all bits, add one, then negate the result. For an 8-bit example, FF in binary is 11111111. The leading bit is 1, so it is negative. Inverting gives 00000000, adding one gives 00000001, which is 1. Negating yields -1.
Selecting a bit width in this tool applies that logic automatically. If your hex string has fewer bits than the selected width, it is padded with leading zeros. The binary and octal results show the two's complement bit pattern, so FF at 8 bits is 11111111 and 377. If it needs more bits than the width, the tool shows an error instead of silently dropping the high bits.
Common hexadecimal reference values
The table below lists frequently encountered hex values and their decimal equivalents in both unsigned and signed 8-bit interpretations.
| Hex | Unsigned decimal | Signed 8-bit decimal |
|---|---|---|
| 00 | 0 | 0 |
| 01 | 1 | 1 |
| 7F | 127 | 127 |
| 80 | 128 | -128 |
| FF | 255 | -1 |
| 100 | 256 | error: needs 9 bits |
For wider types, FFFF is 65535 unsigned or -1 as a signed 16-bit integer, and FFFFFFFF is 4294967295 unsigned or -1 as a signed 32-bit integer.
Practical uses for converting hex to dec
Developers encounter hexadecimal constantly. Memory addresses in debuggers, machine code opcodes, network MAC addresses and file format headers are all typically displayed in hex. Converting these to decimal helps when performing arithmetic, comparing magnitudes or passing values to APIs that expect base-10 integers.
Embedded systems engineers often read sensor registers in hex and need to interpret them as signed values. Selecting the correct bit width in this hex to decimal converter ensures the two's complement math matches the hardware register size.
When working with permissions in Unix-like systems, octal is more common, but some tools output hex. This converter shows the octal equivalent alongside the decimal so you can cross-reference without a second tool. For broader base conversions, see the number base converter.
For arithmetic on hex values, try the hex calculator, and for binary input see binary to hex.
Input formatting and edge cases
The input field accepts several common formats. You may include a 0x or 0X prefix, a # symbol, or no prefix at all. Whitespace around the value is trimmed, and upper or lower case letters are treated identically.
A few edge cases to keep in mind:
- An empty input or one containing only a prefix returns an error.
- Characters outside 0-9 and A-F produce a validation error.
- When a signed bit width is chosen and the hex value requires more bits than the width, the tool shows an error. For example,
1FFdoes not fit in 8 bits, whileFFdoes and yields -1. - Very long hex strings (hundreds of digits) work correctly because the calculation relies on BigInt rather than floating-point numbers.
Worked examples
| Example | Input | Result |
|---|---|---|
| Simple byte | Hexadecimal value: FF; Signed two's complement: none | Decimal: 255; Binary: 11111111; Octal: 377; Bytes needed: 1 |
| Signed 8-bit | Hexadecimal value: FF; Signed two's complement: 8 | Decimal: -1; Binary: 11111111; Octal: 377; Bytes needed: 1 |
| With 0x prefix | Hexadecimal value: 0x1A3F; Signed two's complement: none | Decimal: 6719; Binary: 1101000111111; Octal: 15077; Bytes needed: 2 |
| Large 64-bit signed | Hexadecimal value: FFFFFFFFFFFFFFFF; Signed two's complement: 64 | Decimal: -1; Binary: 1111111111111111111111111111111111111111111111111111111111111111; Octal: 1777777777777777777777; Bytes needed: 8 |
| 32-bit negative | Hexadecimal value: #80000000; Signed two's complement: 32 | Decimal: -2147483648; Binary: 10000000000000000000000000000000; Octal: 20000000000; Bytes needed: 4 |
FAQ
How do I convert hex to decimal manually?
Multiply each hex digit by 16 raised to the power of its position from the right, starting at zero, then sum the results. For example, 2A is 2 times 16 plus 10 times 1, which equals 42.
What does the 0x prefix mean?
The 0x prefix is a convention in many programming languages to indicate that the following digits are hexadecimal. This converter strips it automatically so you can paste values directly.
Why would I use signed two's complement?
Two's complement is how most modern processors represent negative integers. If you are reading a hardware register or a binary file that stores signed values, selecting the correct bit width gives you the proper negative decimal.
Can this tool handle very large hex numbers?
Yes. The converter uses JavaScript BigInt, which supports integers of arbitrary size. You can convert hex strings with hundreds of digits without any loss of precision.
Is my data sent to a server?
No. All calculations happen locally in your browser. Nothing you type is uploaded anywhere.
What is the difference between hex to dec and hex to decimal?
There is no difference. "Dec" is simply an abbreviation for decimal. Both terms refer to converting a base-16 number to base-10.
What happens if the hex value is too big for the bit width?
The tool shows an error that names the number of bits needed, for example 100 needs 9 bits and does not fit in 8 bits. Choose a wider type or reduce the value.