toolqik

92 · Encode & Convert

Decimal to Hex

Convert decimal numbers to hexadecimal, with 0x prefix, grouping and two’s complement.

Runs in your browser
Format
Result

  

About this tool

Convert decimal numbers to hexadecimal (base 16), the compact notation programmers use for bytes, memory addresses, colours, Unicode code points and permissions. Enter one number per line; add a 0x prefix or group the digits into bytes with the format options.

How to convert decimal to hex by hand

Divide by 16 repeatedly and write down the remainders as hex digits (10 = A … 15 = F), then read them from last to first:

500 ÷ 16 = 31  remainder 4   → 4
 31 ÷ 16 = 1   remainder 15  → F
  1 ÷ 16 = 0   remainder 1   → 1      → 0x1F4

Why hexadecimal?

One hex digit is exactly 4 bits, so two digits are one byte: FF = 11111111. That makes hex far easier to read than binary while still mapping directly onto bits, which is why it’s used in hex dumps, colour codes (#FF8800), MAC addresses, hashes and error codes.

Negative numbers

Choose a bit width to get the two’s complement form used in memory and debuggers: −1 in 32 bits is FFFFFFFF, and −2 in 16 bits is FFFE.

Features

  • Any size: numbers are converted exactly with arbitrary-precision arithmetic, so 64-bit values and even longer numbers never lose digits (a normal calculator rounds anything above 253).
  • Fractions: 3.75 → 11.11. Fractions that don’t end in the target base, like 0.1 in binary, are cut off after the chosen number of digits and marked with ….
  • Negative numbers with a minus sign, or as two’s complement in 8, 16, 32 or 64 bits, the way computers store signed integers.
  • Flexible input: prefixes (0b, 0o, 0x, #), spaces, underscores and thousands separators are ignored. Convert many numbers at once, one per line.
  • The first number is also shown in every base, with the number of bits it needs.

Quick reference

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
711177
81000108
91001119
10101012A
15111117F
16100002010
321000004020
64100000010040
100110010014464
12711111111777F
1281000000020080
25511111111377FF
256100000000400100
1024100000000002000400

FAQ

How do I convert decimal to hex?

Enter the number and its hex form appears instantly. By hand, divide by 16 repeatedly and read the remainders from last to first, writing 10–15 as A–F.

What is 255 in hex?

FF. 256 is 100, 1000 is 3E8 and 65,535 is FFFF.

How do I add a 0x prefix?

Turn on “Prefix” under Format to get 0xFF instead of FF.

How do I convert negative numbers to hex?

Choose 8, 16, 32 or 64-bit two’s complement under Negative numbers. −1 becomes FF, FFFF, FFFFFFFF or FFFFFFFFFFFFFFFF.

esc
↑↓ navigate↵ open