Decimal to Hexadecimal Conversion — Step by Step Guide
Learn how to convert decimal numbers to hexadecimal using the division-remainder method. Includes worked examples, comparison table, and free converter tool.
Introduction
Hexadecimal (base 16) is one of the most widely used number systems in programming. Whether you are working with CSS colour codes, memory addresses, or debugging binary data, you need to convert decimal to hex frequently. This guide teaches the standard division-by-16 method with clear worked examples.
🔧 Try it now: Decimal to Hex Converter — instant conversion with step-by-step division shown.
The Division-Remainder Method
To convert any decimal number to hexadecimal:
- Divide the decimal number by 16
- Record the remainder (0–15, where 10=A, 11=B, 12=C, 13=D, 14=E, 15=F)
- Use the quotient as the new number
- Repeat until the quotient becomes 0
- Read remainders from bottom to top — that is your hex result
Hex Digit Reference
| Decimal | Hex | Decimal | Hex |
|---|---|---|---|
| 0 | 0 | 8 | 8 |
| 1 | 1 | 9 | 9 |
| 2 | 2 | 10 | A |
| 3 | 3 | 11 | B |
| 4 | 4 | 12 | C |
| 5 | 5 | 13 | D |
| 6 | 6 | 14 | E |
| 7 | 7 | 15 | F |
Worked Examples
Example 1: Convert 255 to Hex
| Step | Division | Quotient | Remainder | Hex Digit |
|---|---|---|---|---|
| 1 | 255 ÷ 16 | 15 | 15 | F |
| 2 | 15 ÷ 16 | 0 | 15 | F |
Read bottom to top: FF
Verification: F×16 + F×1 = 15×16 + 15 = 240 + 15 = 255 ✓
Example 2: Convert 4096 to Hex
| Step | Division | Quotient | Remainder | Hex Digit |
|---|---|---|---|---|
| 1 | 4096 ÷ 16 | 256 | 0 | 0 |
| 2 | 256 ÷ 16 | 16 | 0 | 0 |
| 3 | 16 ÷ 16 | 1 | 0 | 0 |
| 4 | 1 ÷ 16 | 0 | 1 | 1 |
Read bottom to top: 1000
This makes sense — 4096 = 16³, so it is exactly “1” followed by three zeros in hex.
Example 3: Convert 500 to Hex
| Step | Division | Quotient | Remainder | Hex Digit |
|---|---|---|---|---|
| 1 | 500 ÷ 16 | 31 | 4 | 4 |
| 2 | 31 ÷ 16 | 1 | 15 | F |
| 3 | 1 ÷ 16 | 0 | 1 | 1 |
Read bottom to top: 1F4
Comparison: Decimal, Binary, Octal, Hex
| Decimal | Binary | Octal | Hex |
|---|---|---|---|
| 10 | 1010 | 12 | A |
| 16 | 10000 | 20 | 10 |
| 100 | 1100100 | 144 | 64 |
| 255 | 11111111 | 377 | FF |
| 4096 | 1000000000000 | 10000 | 1000 |
Notice how hex is much more compact than binary — every hex digit represents exactly 4 binary bits.
Why Hex is Used in Programming
- CSS colors:
#FF5733= RGB(255, 87, 51) - Memory addresses:
0x7FFFFFFFis easier to read than the binary equivalent - Machine code: Assembly uses hex for opcode bytes
- IPv6 addresses: Written in hex groups (e.g.,
2001:0db8::) - Unicode: Code points like U+0041 = ‘A’
Common Mistakes
- Forgetting A–F mapping — Remainders 10–15 must be written as A–F, not as two decimal digits
- Reading remainders top-down — Always read from the last remainder to the first
- Wrong division — Divide by 16 (not 8 or 2) for hexadecimal
- Confusing hex 10 with decimal 10 — Hex 10 = decimal 16
Frequently Asked Questions
How do I convert decimal to hex quickly?
For numbers under 256, divide by 16 once: quotient is the first hex digit, remainder is the second. For example, 200 ÷ 16 = 12 remainder 8, so 200 = C8 hex.
What is the hex equivalent of decimal 256?
256 ÷ 16 = 16 R0, 16 ÷ 16 = 1 R0, 1 ÷ 16 = 0 R1 → 100 hex. This equals 16² which is exactly “1” followed by two zeros in hex.
Why do CSS colors use hex?
Each color channel (Red, Green, Blue) ranges 0–255, which maps perfectly to two hex digits (00–FF). This gives 6 hex characters for a full RGB color.
Can I convert hex fractions?
This guide covers whole numbers. Fractional hex conversion requires multiplying the decimal fraction by 16 repeatedly — a less common operation.
What is the 0x prefix?
0x is a programming convention indicating a hexadecimal literal. 0xFF means “FF in hex” = 255 decimal. Our converter accepts input with or without this prefix.
Related Calculators
Related Articles
Share this article
Learn Faster with Numverto
Explore free number system converters, binary tools, EMI calculators, GST calculators, and educational guides.
About Numverto
Numverto Editorial Team
Numverto publishes educational content about number systems, computer science concepts, binary arithmetic, financial calculations, EMI formulas, GST calculations, and practical learning resources for students and professionals.
Article Metadata
Tags: decimal, hexadecimal, number systems, conversion
Last Updated: June 2026
Related Calculators
Related Articles
18 June 2026
Octal to Decimal Conversion — Step by Step with Examples
Learn how to convert octal (base 8) numbers to decimal (base 10) using the positional weight method. Includes worked examples, practice problems, and a free converter tool.
Read article →17 June 2026
What is 1's Complement and 2's Complement in Binary?
Learn 1's complement and 2's complement with simple explanations, step-by-step examples, and practice problems for BCA/BTech exams.
Read article →15 June 2026
How to Convert Decimal to Binary — Easy Method with Examples
Learn the repeated division method to convert decimal numbers to binary. Step-by-step examples, practice problems, and a free online converter tool.
Read article →