Home › Converters › Decimal to Hex
Decimal to Hex
You have an ordinary decimal number — an error code, a color value, a memory size — and the tool, document or programming language in front of you wants it in hexadecimal. This decimal to hex converter does the rewrite instantly and exactly: type the decimal number and get clean uppercase hex, with no rounding even on 64-bit values. The base boxes also convert binary and octal in any direction, and the table below the result shows all four bases side by side.
The same value in all four bases
| Base | Value |
|---|---|
| Binary (base 2) | |
| Octal (base 8) | |
| Decimal (base 10) | |
| Hexadecimal (base 16) |
How it works
Hexadecimal is a base-16 counting system. It uses sixteen digits — 0 through 9, then the letters A, B, C, D, E and F standing for ten through fifteen — and each position in a hex number is worth a power of sixteen: 1, 16, 256, 4,096 and so on from the right. Programmers love it because one hex digit always equals exactly four binary bits, so a byte is always two hex digits and long binary strings shrink into short, readable hex.
Decimal is base 10, where positions are worth 1, 10, 100, 1000. Converting decimal to hex means re-expressing the same quantity in sixteens instead of tens. This converter performs that re-expression with exact whole-number arithmetic, so values beyond the range of ordinary floating-point numbers — 64-bit IDs, huge timestamps, long hash fragments — still convert digit-for-digit.
To convert by hand, divide by 16 repeatedly and collect the remainders, as the worked example below shows. To come back from hex to decimal, multiply each hex digit by its place value — 16^0, 16^1, 16^2 from the right — and add. A quick check works too: the final hex digit always equals the original number divided by 16 with remainder, so an even decimal number always ends in an even hex digit, and any number divisible by 16 ends in 0. Swap the base boxes and this tool runs the conversion in every direction, including binary and octal.
Worked example
A web developer in Austin is picking apart a design token and needs the decimal value 2748 written in hexadecimal.
Step 1: Divide 2748 by 16 — 171, remainder 12. Twelve is written as the hex digit C.
Step 2: Divide 171 by 16 — 10, remainder 11. Eleven is the hex digit B.
Step 3: Divide 10 by 16 — 0, remainder 10. Ten is the hex digit A.
Step 4: Read the remainders from last to first: A, B, C — so 2748 is 0xABC in hex.
That is exactly what the converter shows for 2748: ABC. Checking back the other way: A × 256 + B × 16 + C = 2,560 + 176 + 12 = 2,748, so the conversion is confirmed.
Common mistakes and tips
The classic mistake is forgetting that hex has letters: 12 in hex is not twelve — it is 1 × 16 + 2 = 18 in decimal. Any hex string containing A through F is definitely not decimal, but pure-digit hex strings like 100 (which is 256 in decimal) fool people constantly. When a system reports a value, check whether it is labelled decimal or hex before trusting it; memory addresses and error codes are usually hex, often with a 0x prefix.
About that prefix: 0xABC and ABC are the same number — the 0x is just a label programmers add so readers know the base. This converter accepts and ignores the 0x prefix on hex input, and hex letters can be typed in lowercase or uppercase. Also remember that hex digits group neatly by fours from the right when you compare them with binary: each single hex digit is four bits, so ABC is the binary number 1010 1011 1100.
FAQ
What is 2748 in hex?
2748 in decimal is ABC in hexadecimal (often written 0xABC). Divide by 16 three times: remainders 12 (C), 11 (B) and 10 (A), read in reverse order.
How do I convert decimal to hex by hand?
Divide the number by 16 and note the remainder, converting 10–15 to A–F. Repeat with each quotient until it reaches 0, then read the remainders from the last one to the first.
What does the 0x in 0xABC mean?
The 0x is a prefix programmers use to mark a number as hexadecimal; it is not part of the value. 0xABC and ABC are the same number — 2,748 in decimal.
What is 255 in hex?
255 in decimal is FF in hex: 255 ÷ 16 = 15 remainder 15, and 15 is written as F, twice. FF is the largest value in one byte, which is why it caps every color channel.
How large a number can this converter handle?
Far beyond everyday values. It uses exact arbitrary-precision arithmetic, so 64-bit decimal numbers convert to hex digit-for-digit, with none of the rounding a floating-point calculator would introduce past about 15–16 digits.