How to convert from decimal to hexadecimal?
Calculation Steps for the Integer part:
- Divide the decimal number by 16.
- Get the integer quotient and use it for the next iteration.
- Get the remainder and use it for the hex digit.
- Repeat the above steps until the quotient is equal to 0, or after a specified number of steps.
Steps to calculate the fractional part:
- Multiply the fractional part by 16.
- Take the integer part of the product as the fraction digit. Take the fractional part of the product for the next iteration.
- Repeat the steps above until the fractional part becomes 0, or stop after a number of steps if the fractional part does not become 0.
Example:
Convert 25.01562510 to hexadecimal:
Convert the integer part:
Divide by 16 | Quotient | Remainder | Bit |
---|
25/16 | 1 | 9 => 9 | 0 |
1/16 | 0 | 1 => 1 | 1 |
Convert the fraction part:
Multiply by 16 | Product | Remainder | Fraction Digit |
---|
0.0156*16 | 0.25 | 0.25 | 0 => 0 |
0.25*16 | 4 | 0 | 4 => 4 |
Result: 25.01562510 = 19.0416