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.
Decimal, binary, octal and hex from 0 to 32
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 3 | 11 | 3 | 3 |
| 4 | 100 | 4 | 4 |
| 5 | 101 | 5 | 5 |
| 6 | 110 | 6 | 6 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 9 | 1001 | 11 | 9 |
| 10 | 1010 | 12 | A |
| 11 | 1011 | 13 | B |
| 12 | 1100 | 14 | C |
| 13 | 1101 | 15 | D |
| 14 | 1110 | 16 | E |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 17 | 10001 | 21 | 11 |
| 18 | 10010 | 22 | 12 |
| 19 | 10011 | 23 | 13 |
| 20 | 10100 | 24 | 14 |
| 21 | 10101 | 25 | 15 |
| 22 | 10110 | 26 | 16 |
| 23 | 10111 | 27 | 17 |
| 24 | 11000 | 30 | 18 |
| 25 | 11001 | 31 | 19 |
| 26 | 11010 | 32 | 1A |
| 27 | 11011 | 33 | 1B |
| 28 | 11100 | 34 | 1C |
| 29 | 11101 | 35 | 1D |
| 30 | 11110 | 36 | 1E |
| 31 | 11111 | 37 | 1F |
| 32 | 100000 | 40 | 20 |
Decimal, binary, octal and hex from 0 to 32stringmash.com/decimal-to-hex
Sources
Added and reviewed . What's new






