How to Convert Decimal to Hex Step by Step
Converting a decimal to hex (Base-10 to Base-16) integer by hand uses repeated division by 16. Each remainder gives you one hexadecimal digit from right to left (least significant digit to most significant digit):
- Divide the decimal integer by
16and write down both the integer quotient and the remainder (0through15). - Map remainders
10through15to hex letters:10 = A,11 = B,12 = C,13 = D,14 = E,15 = F. - Repeat dividing the new quotient by
16until the quotient reaches0. - Read the remainders from bottom to top (last remainder first) to assemble the hexadecimal number.
Our decimal to hex converter executes this exact procedure in your browser using JavaScript BigInt, printing every division line in the Step-by-Step Calculation box for numbers up to 1,000,000,000,000 and handling arbitrarily large 64-bit, 128-bit, and 256-bit integers with zero rounding errors. Click Swap Direction whenever you need to convert hex back to decimal.
Worked Decimal to Hex Examples
Test any of these verified decimal to hex conversions in the calculator above:
| Decimal Input (Base 10) | Division by 16 Remainders (Bottom → Top) | Hex Output (Base 16) | With 0x Prefix |
|---|---|---|---|
46 |
46 ÷ 16 = 2 r 14 (E), 2 ÷ 16 = 0 r 2 (2) |
2E |
0x2E |
255 |
255 ÷ 16 = 15 r 15 (F), 15 ÷ 16 = 0 r 15 (F) |
FF |
0xFF |
4096 |
4096 = 1 × 16³ (1, 0, 0, 0) |
1000 |
0x1000 |
6719 |
1, 10 (A), 3, 15 (F) |
1A3F |
0x1A3F |
65535 |
15 (F), 15 (F), 15 (F), 15 (F) |
FFFF |
0xFFFF |
3735928559 |
32-bit unsigned integer (8 hex digits) |
DEADBEEF |
0xDEADBEEF |
Walkthrough: Converting 1000₁₀ to Hex
1000 ÷ 16 = 62with remainder862 ÷ 16 = 3with remainder14(E)3 ÷ 16 = 0with remainder3- Reading bottom to top gives
3E8₁₆(0x3E8). You can verify it backwards:(3 × 256) + (14 × 16) + 8 = 768 + 224 + 8 = 1000.
Negative Numbers and the 0x Prefix
In programming languages such as C, C++, JavaScript, Python, and Go, hexadecimal literals are written with a 0x prefix (for example, 0xFF or 0x1000) so the compiler can distinguish Base-16 10 (16₁₀) from Base-10 10. Toggle 0x prefix in the toolbar above to copy code-ready literals directly.
For negative decimal integers like -46, standard mathematical notation keeps the leading minus sign (-2E or -0x2E). Note that low-level hardware registers and fixed-width C types (int8_t, int16_t, int32_t) store negative values in two's complement form instead (for instance, -1 as an 8-bit signed byte is 0xFF, and as a 16-bit signed word is 0xFFFF). If you need to inspect signed two's complement byte values alongside unsigned hex, use our All-in-One Hex Converter.
Real-World Uses for Decimal to Hex Conversion
- CSS and Web Design Colors: RGB color pickers report red, green, and blue channels as decimal numbers from
0to255. Convertingrgb(37, 99, 235)channel-by-channel (37 → 25,99 → 63,235 → EB) produces the CSS hex color#2563EB. - Memory Addresses and Buffer Sizes: Page sizes (
4096bytes =0x1000), 64 KB segments (65536=0x10000), and struct offsets are much easier to align and read in hexadecimal. - Unicode Code Points and Protocols: Character tables, Modbus registers, and CAN bus IDs frequently require converting decimal spec numbers into Base-16 payloads.
Common Manual Conversion Mistakes
- Reading remainders top to bottom: The very first remainder you calculate is the rightmost hex digit, not the leftmost. Reversing the order turns
46₁₀(2E) intoE2(226). - Forgetting to map
10–15toA–F: Writing remainder14literally as14instead ofEcorrupts both the digit count and the value. - Dropping zero remainders: When a quotient divides evenly (such as
256 ÷ 16 = 16 r 0), the0is a real placeholder digit (256₁₀ = 100₁₆).
Related Hex Conversion Tools
- Need to reverse the calculation with positional expansion? Open the Hex to Decimal Converter.
- Inspecting individual 4-bit nibbles or bitmasks? Switch to the Hex to Binary Converter.
- Turning hex byte streams into readable strings or encoding text? Use the Hex to ASCII Converter.
- Working with Unix
chmodmasks or Base-8 values? Try the Hex to Octal Converter, or convert all five formats together on the Hex Converter.