Decimal to Hex Converter
To convert decimal to hex, divide the number by 16 repeatedly and write down each remainder; read the remainders from last to first. For example 255 becomes FF, and 4095 becomes FFF. Enter a whole number below to see every division.
Hexadecimal result
FF
Working
- 255 ÷ 16 = 15, remainder 15 (F)
- 15 ÷ 16 = 0, remainder 15 (F)
- Read the remainders from the last division up to the first: FF.
Example: 255 to hex
- 255 ÷ 16 = 15, remainder 15 (F)
- 15 ÷ 16 = 0, remainder 15 (F)
- Read the remainders from the last division up to the first: FF.
- Result: FF
The repeated division method
Each division by 16 peels off the lowest hex digit. The remainder is a number from 0 to 15, written as 0-9 or A-F. When the quotient reaches 0 you stop and read the remainders upward. The working lists every division, and for long numbers it shows the first 64 and counts the rest, while the result stays exact.
Hex is popular because each digit stands for exactly four bits, so a byte is always two hex digits. That is why colours, memory addresses and byte values are written in hex.
Defaults and limits
Results use uppercase letters A-F with no 0x prefix and no padding, because the tool shows the number itself, not a fixed-width register. Add 0x yourself if your language needs it, and pad with leading zeros to the width you want. The converter uses arbitrary-precision integers, so values beyond 64 bits convert exactly.
Negative numbers: a leading minus sign is treated as a sign and the digits are converted as the absolute value, so the sign is simply kept in front of the result. This is not two’s complement, which is how processors store negative integers and which depends on a fixed bit width. The tool does not assume a width, so it never reinterprets a high bit as a sign.
Whole numbers only
Decimal points and thousands separators are rejected with a message that names the character. Convert the integer and fractional parts separately if you need a fractional hex value; this tool handles whole numbers.
Decimal, binary, hex and octal table (0-15)
| Decimal | Binary (4-bit) | Hex | Octal |
|---|---|---|---|
| 0 | 0000 | 0 | 0 |
| 1 | 0001 | 1 | 1 |
| 2 | 0010 | 2 | 2 |
| 3 | 0011 | 3 | 3 |
| 4 | 0100 | 4 | 4 |
| 5 | 0101 | 5 | 5 |
| 6 | 0110 | 6 | 6 |
| 7 | 0111 | 7 | 7 |
| 8 | 1000 | 8 | 10 |
| 9 | 1001 | 9 | 11 |
| 10 | 1010 | A | 12 |
| 11 | 1011 | B | 13 |
| 12 | 1100 | C | 14 |
| 13 | 1101 | D | 15 |
| 14 | 1110 | E | 16 |
| 15 | 1111 | F | 17 |
Frequently asked questions
- What is 255 in hex?
- FF. 255 ÷ 16 = 15 remainder 15, and 15 is F, so both digits are F.
- What is 256 in hex?
- 100. It is 16 × 16, so it needs three digits.
- How do I write a negative number in hex?
- This tool writes the sign in front, so -255 is -FF. Processors use two’s complement for a fixed width, which is a different representation.
- Is the hex result case sensitive?
- The tool prints uppercase letters, but most languages accept either case.