Decimal to Hex Converter

Convert Base-10 decimal integers to Base-16 hexadecimal (and back) with live division-by-16 steps, 0x prefixes, and BigInt precision.

Examples:
Converting Decimal (Base 10) to Hexadecimal (Base 16).
Step-by-Step Calculation
Runs 100% client-side with BigInt arbitrary-precision arithmetic.

Focused Hex Converters

Switch to a dedicated two-way tool for step-by-step math, nibble mapping, or byte-by-byte text decoding.

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):

  1. Divide the decimal integer by 16 and write down both the integer quotient and the remainder (0 through 15).
  2. Map remainders 10 through 15 to hex letters: 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F.
  3. Repeat dividing the new quotient by 16 until the quotient reaches 0.
  4. 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 = 62 with remainder 8
  • 62 ÷ 16 = 3 with remainder 14 (E)
  • 3 ÷ 16 = 0 with remainder 3
  • 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 0 to 255. Converting rgb(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 (4096 bytes = 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

  1. 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) into E2 (226).
  2. Forgetting to map 10–15 to A–F: Writing remainder 14 literally as 14 instead of E corrupts both the digit count and the value.
  3. Dropping zero remainders: When a quotient divides evenly (such as 256 ÷ 16 = 16 r 0), the 0 is a real placeholder digit (256₁₀ = 100₁₆).

Related Hex Conversion Tools

Frequently Asked Questions

How do you convert decimal to hex manually?

Divide the decimal number by 16 repeatedly and record each remainder (mapping 10–15 to A–F). Stop when the quotient reaches 0, then read the remainders from bottom to top.

What is 255 in hexadecimal?

Decimal 255 equals FF in hexadecimal (or 0xFF with a programming prefix), because 255 ÷ 16 = 15 (F) remainder 15 (F).

Does this decimal to hex converter support negative numbers and 0x prefixes?

Yes. You can enter a leading minus sign (such as -46) to get -2E, and toggle the 0x prefix option in the toolbar to produce code-ready literals like -0x2E or 0xFF.

Can I convert very large 64-bit or 128-bit decimal numbers to hex?

Yes. All conversions use JavaScript BigInt inside your browser, so 64-bit, 128-bit, and 256-bit decimal integers convert to exact hexadecimal without precision loss or server uploads.