Decimal to Hexadecimal Conversion
Converting a decimal number to hexadecimal is a useful technique in computing and digital electronics, especially when working with memory addresses, colors in web design, and low-level programming. The hexadecimal system is base-16, using digits 0–9 and letters A–F to represent values.
What is Decimal?
Decimal is the standard base-10 number system we use in everyday life. It includes digits from 0 to 9. Each digit’s position represents a power of 10. For example, 245 in decimal means: (2×10²) + (4×10¹) + (5×10⁰).
What is Hexadecimal?
The hexadecimal (or hex) system is base-16. It includes digits from 0 to 9 and letters A to F, where A = 10, B = 11, C = 12, D = 13, E = 14, and F = 15. It is widely used in programming, color codes (e.g., #FF5733), and memory representation in computers.
How to Convert Decimal to Hexadecimal (Integer Part)
To convert a whole number (integer) from decimal to hexadecimal:
- Divide the decimal number by 16.
- Record the remainder (convert 10-15 to A-F).
- Continue dividing the quotient by 16 until you reach 0.
- The hexadecimal number is the remainders read from bottom to top.
Example: Convert 345 to Hexadecimal
- 345 \(\div\) 16 = 21 remainder 9 \(\rightarrow\) 9
- 21 \(\div\) 16 = 1 remainder 5 \(\rightarrow\) 5
- 1 \(\div\) 16 = 0 remainder 1 \(\rightarrow\) 1
Reading from bottom to top, 345 in decimal = 159 in hexadecimal.
How to Convert Decimal Fractions to Hexadecimal
To convert a fractional decimal (e.g., 0.625) to hexadecimal:
- Multiply the fractional part by 16.
- The integer part of the result becomes the next hex digit.
- Repeat the process with the new fractional part.
- Stop after a few digits or when the fraction becomes 0.
Example: Convert 0.625 to Hexadecimal
- \(0.625 \times 16 = 10.0 \rightarrow \) Integer part: 10 = A
- Fractional part is now 0, so we stop.
So, 0.625 in decimal = 0.A in hexadecimal.
Example: Convert 0.3 to Hexadecimal
- \(0.3 \times 16 = 4.8 \rightarrow 4 \)
- \(0.8 \times 16 = 12.8 \rightarrow 12 \) = C
- \(0.8 \times 16 = 12.8 \rightarrow \) continues repeating...
So, 0.3 in decimal \(\approx\) 0.4CCCC... (repeating) in hexadecimal.
Combining Integer and Fractional Parts
To convert a decimal number with both integer and fraction (e.g., 345.625):
- Convert the integer part (345 \(\rightarrow\) 159)
- Convert the fractional part (0.625 \(\rightarrow\) A)
- Final hexadecimal: 159.A
Why Convert Decimal to Hexadecimal?
- Hex numbers are shorter and easier to read than binary.
- Used in computer memory addresses and debugging.
- Essential in web development for colors and CSS.
Use Our Decimal to Hexadecimal Calculator
Use our free Decimal to Hexadecimal Calculator above to instantly convert any number-integer or fractional-and view detailed steps showing how it's done.