How to convert from decimal to octal?
Calculation steps for the integer part:
- Divide the decimal number by 8.
- Get the integer quotient and use it for the next iteration.
- Get the remainder and use it for the octal 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 8.
- 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 15.062510 to octal:
Convert the integer part:
Divide by 8 | Quotient | Remainder | Bit |
---|
15/8 | 1 | 7 | 0 |
1/8 | 0 | 1 | 1 |
Convert the fraction part:
Multiply by 8 | Product | Remainder | Fraction Digit |
---|
0.0625*8 | 0.5 | 0.5 | 0 |
0.5*8 | 4 | 0 | 4 |
Result: 15.062510 = 17.048