Decimal to Hex Converter
Convert decimal to hex as you type and see the repeated division by 16 that produces each digit. Works for numbers of any size, and gives the two's complement hex of negative numbers.
Whole numbers of any size. Commas and spaces are ignored, and a minus sign is allowed.
| Binary | | |
|---|---|---|
| Octal | | |
| Decimal | | |
| Hex | | |
| Bit length | |
Show steps
Divide the decimal number by the new base again and again until the quotient is 0. The remainders, read from the bottom up, are the digits of the result.
| Division | Quotient | Remainder | Digit |
|---|
Two's complement view (signed numbers)
Auto picks the smallest of 8, 16, 32 or 64 bits that holds the number as a signed value.
| Width | | |
|---|---|---|
| Bits | | |
| Hex | | |
| Unsigned | | |
| Signed | |
Convert Decimal Numbers to Hexadecimal Online
Programmers write numbers in hex because every hex digit is exactly 4 bits, which makes bytes, masks and addresses short and easy to read. This decimal to hex converter writes any whole number in base 16 while you type.
The steps table shows the repeated division by 16 for your number, with each remainder turned into its hex digit. Add a 0x prefix for code, or use the two's complement view to get the hex of a negative number.
How to use the decimal to hex converter
- Type a decimal number, for example
48879. - Copy the hex result,
BEEF. Tick "Show prefix" to get0xBEEF. - Check the steps, or open the two's complement view for negative numbers.
How to convert decimal to hex: divide by 16
Divide the number by 16 and note the remainder (0 to 15). Divide the quotient by 16 again until it reaches 0. Write remainders 10 to 15 as A to F, then read them from the bottom up. For 48879:
| Division | Quotient | Remainder |
|---|---|---|
| 48879 ÷ 16 | 3054 | 15 = F |
| 3054 ÷ 16 | 190 | 14 = E |
| 190 ÷ 16 | 11 | 14 = E |
| 11 ÷ 16 | 0 | 11 = B |
Reading upward gives BEEF. Check: 11 × 4096 + 14 × 256 + 14 × 16 + 15 = 48,879.
Shortcut: go through binary
If you already know the binary form, split it into groups of 4 bits from the right and replace each group with one hex digit. 200 is 1100 1000 in binary, and 1100 = C, 1000 = 8, so 200 is C8. The decimal to binary converter groups bits in fours for you.
Decimal to hex table
| Decimal | Hex | Decimal | Hex |
|---|---|---|---|
| 10 | A | 255 | FF |
| 15 | F | 256 | 100 |
| 16 | 10 | 1,000 | 3E8 |
| 32 | 20 | 1,024 | 400 |
| 64 | 40 | 4,096 | 1000 |
| 100 | 64 | 65,535 | FFFF |
| 127 | 7F | 65,536 | 10000 |
| 128 | 80 | 1,000,000 | F4240 |
Negative numbers in hex
Computers store −1 with every bit set, so in two's complement it is FF in 8 bits, FFFF in 16 bits and FFFFFFFF in 32 bits. For other values, add 2width: −42 in 8 bits is 256 − 42 = 214, which is D6.
With a plain minus sign the converter writes -2A for −42. The two's complement view gives the bit pattern for 8, 16, 32 or 64 bits.
Where decimal to hex is used
- CSS colors: rgb(79, 70, 229) is 4F, 46 and E5, so
#4F46E5. The RGB to HEX converter does all three channels at once. - Unicode and HTML: 9786 is
263A, so☺shows ☺. - Code: Python
hex(255)gives0xff, and JavaScript(255).toString(16)givesff.
Frequently Asked Questions
Common questions about converting decimal numbers to hexadecimal.
Divide by 16 repeatedly, write down each remainder as a hex digit (10 = A … 15 = F) and read them from the last to the first. 255 gives 15 and 15, so it is FF.
255 is FF, the largest value of one byte.
16 is 10 in hex: one sixteen and zero ones.
1000 is 3E8: 3 × 256 + 14 × 16 + 8.
Two. A byte is 8 bits and each hex digit is 4 bits, so values 0 to 255 are 00 to FF.
It does not matter: FF and ff are the same value. The converter uses upper case, which is easier to read.
Use the two's complement view and choose a width. -1 is FF in 8 bits and FFFFFFFF in 32 bits.
Use the hex to decimal converter, which adds up the powers of 16.