Decimal to hex converter
Convert decimal to hexadecimal: type a decimal number to get it in hex, with the division steps.
Prefixes 0b, 0o, 0x and spaces or underscores between digits are fine. A point starts the fraction.
How to convert decimal to hex
Divide by 16 and note the remainder, which is between 0 and 15. Write remainders 10 to 15 as A to F. Keep dividing the quotient by 16 until it reaches 0, then read the remainders from the bottom up.
| Divide | Quotient | Remainder |
|---|---|---|
| 419 ÷ 16 | 26 | 3 |
| 26 ÷ 16 | 1 | A |
| 1 ÷ 16 | 0 | 1 |
Reading the remainders from the bottom up gives 1A3, so 41910 = 1A316.
Common values
| Decimal | Hex | Where you see it |
|---|---|---|
| 255 | FF | Largest value of one byte |
| 4,095 | FFF | Largest 12-bit value |
| 65,535 | FFFF | Largest 16-bit value |
| 16,777,215 | FFFFFF | White in a 24-bit colour, #FFFFFF |
| 2,147,483,647 | 7FFFFFFF | Largest signed 32-bit integer |
| 4,294,967,295 | FFFFFFFF | Largest unsigned 32-bit integer |
How it’s calculated
Conversions use exact whole-number arithmetic (JavaScript BigInt), so long numbers keep every digit. Fractions are kept as exact ratios; when the digits repeat, the repeating block is found and marked instead of rounded.
Questions
How do I write a negative number in hex?
Programs store it in two’s complement. Tick “Read as signed”, pick the width, and −1 becomes FF in 8 bits or FFFFFFFF in 32 bits.
Why is hex used so much?
One hex digit is exactly four bits, so two hex digits describe one byte. That makes memory addresses, colours and byte dumps much shorter to write than binary.
Can it convert decimals with a fraction?
Yes. 0.5 is 0.8 in hex, because 8/16 = 1/2. Fractions that don’t end in hex are marked as repeating.