Decimal to Hexadecimal Converter
Enter any whole number below and this converter returns its hexadecimal (base 16) equivalent in uppercase notation, along with the binary (base 2) and octal (base 8) representations. The step-by-step panel shows every division-by-16 iteration so you can follow the math. Negative integers are shown with a minus sign prefix; fractional parts are truncated to the integer portion.
What is hexadecimal?
Hexadecimal is a base-16 number system that uses sixteen distinct symbols: the digits 0-9 for values zero through nine, and the letters A, B, C, D, E, and F for values ten through fifteen. Because 16 = 2^4, each hex digit maps exactly to four binary bits, making hexadecimal a compact, human-readable shorthand for binary data. Computer scientists and programmers use hex constantly: memory addresses, color codes, character encoding, and machine instructions are all routinely expressed in hexadecimal.
How to convert decimal to hexadecimal
The standard method is repeated division by 16. Divide the decimal number by 16, record the remainder (0-15, written as 0-9 or A-F), then divide the quotient by 16 again. Repeat until the quotient reaches zero. Reading the remainders from last to first gives the hexadecimal result. For example, converting 255: 255 / 16 = 15 remainder 15 (F); 15 / 16 = 0 remainder 15 (F). Reading bottom-to-top gives FF. The step-by-step panel above works through every division for your chosen number.
Hex in programming and web design
In most programming languages (C, C++, Java, JavaScript, Python, and many others), hexadecimal literals are written with a 0x prefix, for example 0xFF for 255. In CSS and HTML, colors are specified as #RRGGBB where each pair of hex digits represents the red, green, and blue intensity from 00 (none) to FF (full). A common 8-bit unsigned byte ranges from 0x00 to 0xFF (decimal 0-255). A 32-bit unsigned integer spans 0x00000000 to 0xFFFFFFFF (decimal 0-4,294,967,295). This converter lets you choose between plain hex, 0x-prefixed, or #-prefixed output to match the format your use-case requires.
Decimal, binary, octal, and hexadecimal together
All four common numeral bases relate to each other through powers of 2. Binary (base 2) is the native language of digital hardware; octal (base 8) groups binary digits in threes and was widely used in older Unix systems; hexadecimal (base 16) groups binary digits in fours and is the dominant shorthand used today. A single hex digit represents exactly 4 bits, so a byte (8 bits) is always two hex digits (00-FF), a 16-bit word is four hex digits (0000-FFFF), and a 32-bit double-word is eight hex digits. This neat alignment is why hex, not octal, became the standard for memory dumps and color codes.
Decimal to hexadecimal reference chart (0-30)
| Decimal | Hex | Binary | Octal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 2 | 10 | 2 |
| 3 | 3 | 11 | 3 |
| 4 | 4 | 100 | 4 |
| 5 | 5 | 101 | 5 |
| 6 | 6 | 110 | 6 |
| 7 | 7 | 111 | 7 |
| 8 | 8 | 1000 | 10 |
| 9 | 9 | 1001 | 11 |
| 10 | A | 1010 | 12 |
| 11 | B | 1011 | 13 |
| 12 | C | 1100 | 14 |
| 13 | D | 1101 | 15 |
| 14 | E | 1110 | 16 |
| 15 | F | 1111 | 17 |
| 16 | 10 | 10000 | 20 |
| 17 | 11 | 10001 | 21 |
| 18 | 12 | 10010 | 22 |
| 19 | 13 | 10011 | 23 |
| 20 | 14 | 10100 | 24 |
| 25 | 19 | 11001 | 31 |
| 30 | 1E | 11110 | 36 |
| 32 | 20 | 100000 | 40 |
| 40 | 28 | 101000 | 50 |
| 50 | 32 | 110010 | 62 |
| 64 | 40 | 1000000 | 100 |
| 100 | 64 | 1100100 | 144 |
| 128 | 80 | 10000000 | 200 |
| 200 | C8 | 11001000 | 310 |
| 255 | FF | 11111111 | 377 |
| 256 | 100 | 100000000 | 400 |
| 1000 | 3E8 | 1111101000 | 1750 |
| 65535 | FFFF | 1111111111111111 | 177777 |
Quick-reference values for the first 31 decimal integers and selected larger values.
Frequently asked questions
What is the hexadecimal equivalent of decimal 255?
Decimal 255 is FF in hexadecimal. This is the maximum value of an 8-bit unsigned byte. Each F represents the decimal value 15 (binary 1111), so FF = 15 x 16 + 15 = 255. It is also 0xFF in C-style notation and #FF as a two-digit color component in CSS.
How do I convert a large decimal number to hex by hand?
Use repeated division by 16. Divide the number by 16, write down the remainder (converting 10-15 to A-F), then divide the quotient by 16 again. Keep going until the quotient is 0. Read the remainders from bottom to top. For example, 1000 / 16 = 62 remainder 8; 62 / 16 = 3 remainder 14 (E); 3 / 16 = 0 remainder 3. Reading upward: 3E8. So 1000 decimal = 3E8 hex.
What does the 0x prefix mean in hexadecimal?
The 0x prefix is a programming convention that tells the compiler or interpreter the following characters are a hexadecimal literal, not a decimal number. It originated in the C programming language and is now standard in C++, Java, JavaScript, Python, and most other languages. For example, 0xFF and 255 represent the same value; the 0x prefix just signals the base. In CSS and HTML colors, the # symbol serves the same purpose (e.g., #FF0000 for red).
Can this converter handle negative decimal numbers?
Yes. Negative numbers are converted by taking the absolute value, converting it to hex, and prepending a minus sign. This is the signed-magnitude representation. Note that in low-level programming, negative integers are often represented differently (typically in two's complement), where for example -1 in an 8-bit register is 0xFF. If you need two's complement hex, take the positive magnitude, subtract it from 2^n (where n is your bit width), and convert the result.
Why are only 16 symbols used in hexadecimal?
Hexadecimal is base 16, meaning each position in the number represents a power of 16. You need exactly 16 symbols, one for each value from 0 to 15, to fill every digit position. The digits 0-9 cover values zero through nine, and the letters A through F cover values ten through fifteen. This system maps perfectly onto four binary digits (nibbles), making it far more compact than writing out binary while still being straightforwardly convertible to and from the binary that computers use internally.
How is hexadecimal used in color codes?
Web and graphic design represent colors as six-digit hex codes in the format #RRGGBB. The first two digits are the red intensity (00-FF), the middle two are green, and the last two are blue. For example, #FF0000 is pure red, #00FF00 is pure green, #0000FF is pure blue, and #FFFFFF is white (all channels at maximum). Each pair of hex digits corresponds to a decimal value from 0 (no intensity) to 255 (full intensity), giving 256 levels per channel and over 16 million colors in total.