Decimal to Hex Converter
Type a decimal number and get the hex value as you type, with binary and the stored form of negative numbers. Paste a list to convert many at once. Switch direction to go from hex to decimal.
3000 ÷ 16 → remainders 8, 11, 11 → BB8
Commas like 1,000,000 are fine. Separate several numbers with spaces or new lines.
BB8
How to Convert Decimal to Hex
Hex counts in sixteens, using 0–9 and then A–F for ten to fifteen. The standard way to convert is to keep dividing by 16 and collect the remainders:
- Divide the number by 16. Write down the whole-number answer and the remainder.
- Divide that answer by 16 again, and keep going until the answer is 0.
- Turn each remainder into a hex digit: 10 = A, 11 = B, 12 = C, 13 = D, 14 = E, 15 = F.
- Read the remainders from the last one to the first. That's the hex number.
On a calculator, the remainder is the part after the point times 16: 3000 ÷ 16 = 187.5, and 0.5 × 16 = 8.
Worked Example: 3000 to Hex
Convert 3000 to hexadecimal.
Step 1: Divide 3000 by 16
Step 2: Divide 187 by 16
Step 3: Divide 11 by 16
Step 4: Read the remainders from the bottom up
Result: 3000 in decimal = BB8 in hex. Check it backwards: 11 × 256 + 11 × 16 + 8 = 2,816 + 176 + 8 = 3,000.
Decimal to Hex Chart
Everyday numbers and their hex values. Notice where a new digit appears: 16 becomes 10, 256 becomes 100 and 4,096 becomes 1000.
| Decimal | Hex |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 9 | 9 |
| 10 | A |
| 11 | B |
| 12 | C |
| 13 | D |
| 14 | E |
| 15 | F |
| 16 | 10 |
| 17 | 11 |
| 20 | 14 |
| 32 | 20 |
| 50 | 32 |
| 64 | 40 |
| 100 | 64 |
| 127 | 7F |
| 128 | 80 |
| 200 | C8 |
| 255 | FF |
| 256 | 100 |
| 500 | 1F4 |
| 1,000 | 3E8 |
| 1,024 | 400 |
| 2,048 | 800 |
| 4,096 | 1000 |
| 10,000 | 2710 |
| 65,535 | FFFF |
| 65,536 | 10000 |
| 1,000,000 | F4240 |
Common Mistakes
| Mistake | Wrong | Right |
|---|---|---|
| Reading the remainders top to bottom | 8BB | BB8 |
| Writing a remainder of 11 as "11" instead of B | 11118 | BB8 |
| Dropping a remainder of 0 (256 ÷ 16 = 16 r 0, 16 ÷ 16 = 1 r 0) | 1 | 100 |
| Using the decimal part as the remainder (187.5 → 5) | BB5 | BB8 |
For color codes, convert each of the red, green and blue values separately and pad each to two digits: 200, 100, 50 becomes C8 64 32, or #C86432. The RGB to HEX converter does this in one step.
Negative Numbers in Hex
On paper, −255 in hex is simply −FF. Computers don't store a minus sign, though. They count back from the top of a fixed size, so −1 is stored as FF in one byte, FFFF in two bytes and so on. This is called two's complement. When you enter a negative number, the tool shows both: the plain answer and the stored form at the smallest common size that fits.
| Decimal | Written | Stored (two's complement) |
|---|---|---|
| −1 | −1 | FF (8 bits) |
| −5 | −5 | FB (8 bits) |
| −128 | −80 | 80 (8 bits) |
| −255 | −FF | FF01 (16 bits) |
| −40,000 | −9C40 | FFFF63C0 (32 bits) |
Decimal to Hex in Excel, Python and JavaScript
| Tool | How | Result for 3000 |
|---|---|---|
| Excel or Google Sheets | =DEC2HEX(3000) | BB8 |
| Excel (padded to 4 digits) | =DEC2HEX(3000, 4) | 0BB8 |
| Python | format(3000, "X") | BB8 |
| JavaScript | (3000).toString(16).toUpperCase() | BB8 |
| Windows Calculator | Programmer mode → DEC → type 3000 → read HEX | BB8 |
Python's hex(3000) also works but adds 0x and uses lowercase (0xbb8). For negative numbers, Excel's DEC2HEX returns the 10-digit stored form, so =DEC2HEX(-1) gives FFFFFFFFFF.
Frequently asked questions
What is 255 in hex?
FF. 255 ÷ 16 = 15 remainder 15, and 15 is F, so both digits are F. It is the largest number that fits in two hex digits.
What is 10 in hex?
A. Hex uses the letters A to F for the values ten to fifteen, so 10 is A and 15 is F. 16 is written 10 in hex.
How do I always get two digits, like 0A instead of A?
Add a 0 in front of any single-digit answer. In Excel use =DEC2HEX(10, 2), and in Python format(10, "02X").
Can I convert a number with a decimal point?
This tool works with whole numbers. Fractions in hex are rare outside computer science courses, and most decimal fractions never end in hex.
Sources
- Microsoft Support: DEC2HEX function: the places argument for padding and how negative numbers are returned.
- MDN: Number.prototype.toString(): writing a number in base 16.
Related Tools
Convert Base64 encoded data into hexadecimal values.
Convert hexadecimal values into Base64 encoded data.
Convert binary values into hexadecimal numbers.
Convert CMYK color values into HEX color codes.
Convert HEX color codes into CMYK color values.
Convert hexadecimal values into decimal integers.