Decimal to Hex Converter
Convert a decimal number to hexadecimal — the compact base-sixteen form used for colours, bytes and addresses.
Divide repeatedly by sixteen and read the remainders backwards, using A to F for ten to fifteen.
How the decimal to hex converter works
Divide repeatedly by sixteen and read the remainders backwards, using A to F for ten to fifteen. Because two hex digits hold exactly one byte, values are usually padded to an even length — 15 is written 0F rather than F when it represents a byte.
Formula: value = Σ digitₖ × bᵏ
Worked examples
| Inputs | Converted | Note |
|---|---|---|
| 255 | FF | FF |
| 4096 | 1000 | 1000 |
| 3405691582 | CAFEBABE | CAFEBABE |
FAQFrequently asked questions
How do I convert decimal to hex?
Divide by sixteen repeatedly and read the remainders backwards, writing 10–15 as A–F.
What is 255 in hex?
FF.
Why pad to two digits?
Because two hex digits are exactly one byte, so 15 becomes 0F when it stands for a byte value.
How do I write a colour?
Three bytes, red then green then blue: pure orange is #FF8800.
Is hex case-sensitive?
No — FF and ff mean the same. Upper case is the more common convention.
Where these figures come from
- NIST Digital Library of Mathematical Functions — reference definitions for elementary and special functions
- Wolfram MathWorld — definitions and formulas for every topic on this page
- NIST/SEMATECH e-Handbook of Statistical Methods — the statistical formulas (mean, variance, z, confidence intervals, sample size)
- National curriculum in England — Mathematics — the terms and methods taught in UK schools
Last checked: September 2026. Formulas are fixed by mathematics and do not change with tax years or regulations.