Hexadecimal Converter
Convert hexadecimal (base 16) to decimal and decimal to hex instantly, including negative numbers, two's complement for 8, 16, 32 and 64 bits, and numbers of any size.
- 100% free
- No signup
- Runs in your browser
How to use
- To convert hex to decimal, type the hex number in the Hexadecimal field, for example FF, 0xFF or 0FFh.
- To convert decimal to hex, type a whole number in the Decimal field. Negative numbers such as -1 are allowed.
- Read the result in the other field. The table below it shows the same value as a signed 8-, 16-, 32- and 64-bit integer in two's complement.
How hexadecimal works
Hexadecimal is a base-16 number system. It uses the digits 0–9 and the letters A–F, where A = 10, B = 11, C = 12, D = 13, E = 14 and F = 15. Each position is worth 16 times the position to its right.
Programmers use hex because one hex digit stands for exactly four bits, so a byte is always two hex digits (00 to FF). Colors such as #FF8800, memory addresses and character codes are usually written in hex.
To convert hex to decimal, multiply each digit by 16 raised to the power of its position, counting from 0 on the right, and add the results. For 2F3: 2 × 16² + 15 × 16 + 3 = 512 + 240 + 3 = 755.
To convert decimal to hex, divide by 16 again and again and write down the remainders from last to first. 755 ÷ 16 = 47 remainder 3, 47 ÷ 16 = 2 remainder 15 (F), 2 ÷ 16 = 0 remainder 2, so 755 = 2F3.
Common hex values
| Value | Hexadecimal = decimal |
|---|---|
| Largest one-byte value (8 bits) | FF = 255 |
| Largest 16-bit value | FFFF = 65535 |
| Largest 32-bit value | FFFFFFFF = 4294967295 |
| The number 16 | 10 = 16 |
| The number 100 | 64 = 100 |
Computers store negative integers in two's complement: the stored value is 2ⁿ plus the negative number, where n is the number of bits. That is why -1 is FF in 8 bits, FFFF in 16 bits and FFFFFFFF in 32 bits, and -2 is FE, FFFE and FFFFFFFE.
Examples
| Example | Result |
|---|---|
| Hex FF to decimal | 15 × 16 + 15 = 255 |
| Hex 0x1A3 to decimal | 1 × 256 + 10 × 16 + 3 = 419 |
| Decimal 1000 to hex | 3 × 256 + 14 × 16 + 8 = 3E8 |
| Decimal -1 to hex (32-bit) | FFFFFFFF |