StringMash.com

Decimal to hex converter

Decimal to hexadecimal, dividing by 16 with each step shown.

Conversion
3 characters
Updates as you type
Swap for hex to decimal

Show the steps
  1. 500 ÷ 16 = 31 remainder 4
  2. 31 ÷ 16 = 1 remainder 15, which is F
  3. 1 ÷ 16 = 0 remainder 1
  4. Read the remainders from the bottom up: 1F4
Printable chart

Using the converter

Type a decimal number, like 500, and its hexadecimal form appears straight away, with the division that produced it underneath. Numbers of any length work, negative ones too, and you can put several in at once, separated by spaces, commas or new lines. Choose capitals (1F4) or lowercase (1f4) letters in the settings.

To go the other way, press swap, or use the hex to decimal page. The menus switch between decimal, binary, octal and hex in any direction. Binary and octal each have their own pages too, with the same step-by-step working and the table of the first 33 numbers.

How to convert decimal to hex

Divide the number by 16 and write down the remainder. Divide the answer by 16 again, and keep going until the answer is 0. The remainders, read from the last one back up to the first, are the hex digits. Remainders from 10 to 15 are written as the letters A to F. It's quicker than it sounds.

For 500, 500 ÷ 16 = 31 remainder 4, then 31 ÷ 16 = 1 remainder 15, which is F, then 1 ÷ 16 = 0 remainder 1. Reading upwards gives 1F4. To check, 1 × 256 + 15 × 16 + 4 = 500.

A shortcut through binary

For a number you already know in binary, there's no need to divide at all. Split the bits into groups of four from the right, and turn each group into one hex digit, since 16 is 2⁴. That's why programmers use hex as shorthand for binary, two hex digits to a byte.

Questions

What is 255 in hex?

FF. 255 ÷ 16 = 15 remainder 15, and 15 is F in both places. It's the largest number that fits in one byte, which is why colour codes stop at FF.

What is 16 in hex?

10. One sixteen and no ones, the same way 10 in decimal means one ten and no ones.

Why is hex written with 0x?

0x in front, as in 0x1F4, tells a programming language the number is hex. The converter accepts it on hex input and leaves it off its answers.

Can it convert decimals with a fractional part?

No, it converts whole numbers only. For floating-point numbers as a computer stores them, try the IEEE 754 converter.

THE FIRST 33 NUMBERS

Decimal, binary, octal and hex from 0 to 32

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
17100012111
18100102212
19100112313
20101002414
21101012515
22101102616
23101112717
24110003018
25110013119
2611010321A
2711011331B
2811100341C
2911101351D
3011110361E
3111111371F
321000004020

Sources

Added and reviewed . What's new