Decimal to Hex Converter
Convert any decimal number to hexadecimal instantly, with the full repeated-division-by-16 breakdown showing exactly how the result is built.
How to Convert Decimal to Hex
Divide the decimal number by 16 and keep the remainder — that's the rightmost hex digit. Take the quotient from that division and divide it by 16 again, keeping that remainder as the next digit to the left. Repeat until the quotient reaches 0, then read the remainders in reverse order.
Each remainder is always between 0 and 15, since you're dividing by 16 — so it always fits in exactly one hex digit, with 10-15 written as A-F.
Decimal to Hex Example, Step by Step
3000 = BB8
3000 (decimal) = BB8 (hex)
3000 / 16 = 187 remainder 8 187 / 16 = 11 remainder B 11 / 16 = 0 remainder B Read bottom to top: B B 8
| Step | Description | Result |
|---|---|---|
| Divide 3000 by 16 | quotient 187, remainder 8 | 8 |
| Divide 187 by 16 | quotient 11, remainder 11 (B) | B |
| Divide 11 by 16 | quotient 0, remainder 11 (B) | B |
| Read remainders in reverse | last remainder first | BB8 |
The process stops once the quotient hits 0 — that's the same signal decimal long division uses, just with 16 as the divisor instead of 10.
How Many Hex Digits Will I Need?
Each extra hex digit multiplies the range by 16, so you can estimate the digit count before converting anything.
| Decimal range | Hex digits needed | Largest value |
|---|---|---|
| 0-15 | 1 digit | F |
| 16-255 | 2 digits | FF |
| 256-4,095 | 3 digits | FFF |
| 4,096-65,535 | 4 digits | FFFF |
Where Decimal to Hex Actually Comes Up
Writing Hex Literals in Code
Color constants, bitmask flags, and memory addresses in code are almost always written in hex — converting a decimal value you already know into its hex literal is a near-daily task for anyone writing low-level or graphics code.
3000 -> 0xBB8
Reading Memory Addresses and Offsets
Debuggers print addresses in hex, but you often reason about them in decimal first — converting back and forth lets you translate a decimal offset into the address format your tools actually show you.
65535 -> 0xFFFF
Encoding a Timestamp or ID as Hex
Unix timestamps, database IDs, and short unique identifiers are frequently hex-encoded for compactness — this is the conversion that turns a plain decimal number into that compact hex string.
170 -> 0xAA
Common Mistakes When Converting Decimal to Hex
- Reading the remainders top to bottom instead of reversing them.
- Writing a remainder of 10-15 as two digits instead of its single hex letter.
- Trying to apply this method directly to a negative number instead of using a signed representation.
- Stopping one division too early, before the quotient actually reaches 0.
Why Use This Calculator Instead of Doing It by Hand
- Shows every division and remainder, so you can check your own by-hand math
- Runs entirely in your browser — nothing you type gets sent anywhere
- Handles numbers of any size, not just what fits neatly on paper
- Gives binary and octal for the same value at once, no extra lookups
Frequently Asked Questions
How do you convert decimal to hex by hand?
Divide the number by 16, write down the remainder, then keep dividing the quotient by 16 until it reaches 0. Reading the remainders from last to first gives the hex value.
Why do you read the remainders backwards?
The first division finds the ones-place digit (16^0), and each division after that finds the next digit up. Since you calculate the smallest place value first but write numbers with the largest place value first, the order has to flip.
What if a remainder is 10 or higher?
Write it as its hex letter instead of two digits — 10 becomes A, 11 becomes B, and so on up to 15 becoming F. A remainder is always 0-15, since you're dividing by 16, so it never needs more than one hex digit.
Can negative decimal numbers be converted this way?
Not directly — this method assumes a non-negative number. Negative values need a signed representation like two's complement at a fixed bit width, which encodes the sign into the bits rather than using a minus sign.
How many hex digits will my decimal number need?
Compare it against powers of 16: under 16 needs 1 digit, under 256 needs 2, under 4096 needs 3, and under 65536 needs 4 — each additional digit multiplies the range by 16.
Is there a faster way than doing it by hand?
Yes — most languages have a built-in conversion, like JavaScript's Number(170).toString(16) or Python's hex(170), both of which return "aa".
What is 3000 in hex?
BB8 — dividing 3000 by 16 repeatedly gives remainders 8, then B, then B, and reading them in reverse gives BB8. It's also the worked example above if you want to see every step.
What's the fastest way to estimate a hex conversion without a calculator?
Find the largest power of 16 (1, 16, 256, 4096...) that fits into your number, divide to get the leading digit, then repeat on the remainder — it's slower than repeated division by hand but useful for a quick sanity check on a calculator's answer.