Tools
EN

Decimal to Hexadecimal Converter

Enter a decimal number to get its hexadecimal value instantly, with the division by 16 worked out for you. Negative numbers can also be shown as two's complement for 8, 16, 32 or 64 bits.

Tip: enter one number per line to convert a whole list.

In all bases

Hexadecimal
Decimal
Binary
Octal

Private: your data is processed in your browser and never uploaded.

How to convert decimal to hex

  1. Enter a decimal number, or a list with one number per line. Negative numbers and fractions such as 0.75 work too.
  2. The hex result appears instantly, along with binary and octal. The step-by-step table shows every division by 16 and its remainder.
  3. For the two's-complement hex of a negative number, tick Signed (two's complement) and choose the bit width: −1 becomes FF in 8 bits and FFFFFFFF in 32 bits.

How to convert decimal to hexadecimal by hand

Use repeated division by 16:

  1. Divide the number by 16 and write down the remainder (0–15).
  2. Divide the quotient by 16 again, and repeat until the quotient is 0.
  3. Write each remainder as a hex digit (10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F) and read them from the last to the first.

Example: convert 6719 to hex.

DivisionQuotientRemainder
6719 ÷ 1641915 = F
419 ÷ 16263
26 ÷ 16110 = A
1 ÷ 1601

Reading the remainders from bottom to top gives 1A3F. Check: 1 × 4096 + 10 × 256 + 3 × 16 + 15 = 6719.

Decimal fractions in hex

For the part after the decimal point, multiply by 16 instead of dividing: the whole-number part of each product is the next hex digit. 0.75 × 16 = 12, so 0.75 = 0.C in hex.

Some fractions never end in hex. 0.1 × 16 = 1.6 gives the digit 1, then 0.6 × 16 = 9.6 gives 9, and the 9 repeats forever, so 0.1 = 0.1999…. The converter rounds such values to 12 hex digits (0.19999999999A) and marks them with ≈.

Negative decimal numbers in hex (two's complement)

Computers store a negative number −n in w bits as 2ʷ − n. To find the pattern, add 2ʷ to the negative value and convert the result to hex: −26 in 8 bits is 256 − 26 = 230 = E6.

Decimal8-bit16-bit32-bit
−1FFFFFFFFFFFFFF
−2FEFFFEFFFFFFFE
−26E6FFE6FFFFFFE6
−12880FF80FFFFFF80

Frequently asked questions

What is 255 in hex?

255 in hex is FF: 255 ÷ 16 = 15 remainder 15, then 15 ÷ 16 = 0 remainder 15, and both remainders are written as F. FF is the largest value of one byte.

How do I convert decimal to hex in Excel, Python or JavaScript?

Excel and Google Sheets: =DEC2HEX(255) gives FF. Python: format(255, 'X') gives FF and hex(255) gives 0xff. JavaScript: (255).toString(16) gives ff. In Excel, negative numbers come out as 10-digit two's complement: =DEC2HEX(-1) is FFFFFFFFFF.

Why does 0.1 not convert exactly to hex?

Because 1/10 cannot be written as a finite sum of sixteenths, 256ths and so on, its hex digits repeat forever (0.1999…), just like 1/3 = 0.333… in decimal. Fractions built from halves, quarters, eighths or sixteenths are exact: 0.5 = 0.8 and 0.75 = 0.C in hex.

Can I convert very large numbers?

Yes. The converter uses arbitrary-precision arithmetic, so 18446744073709551616 (2⁶⁴) gives exactly 10000000000000000 – far beyond the 2⁵³ limit of ordinary JavaScript numbers.