Decimal to Octal and viceversa - Base Conversion
MatrixLab Examples
To see a base conversion calculator, see: http://matrixlab-examples.com/base-conversion.html
I'm gonna show you how to convert an octal number to a decimal one, and a decimal number to an octal base.
Any digit in a decimal number has a different weight. The weight is the power of its position in the number.
The same concept can be applied to numbers in any other base. We can obtain the equivalent number in base 10 just by adding every digit multiplied by the base to the corresponding power.
For numbers less than the unit, we have to consider negative powers, just as they are considered in numbers of base 10.
To convert decimal numbers to octal ones, we are going to iterate divisions by 8. We are going to take the remainder for the result, and we are going to take the quotient for another division.
We are going to divide by the base until our quotient becomes less than the base. We have to include our last quotient and our last reminder for the final result in base 8.
This is another example to convert base 10 to octal.
To convert decimal numbers that happen to be less than the unit, we are going to iterate multiplications by the base (in this case it's 8). The integer part of each result goes to our conversion result and the fractional part goes to another multiplication.
The final conversion is an approximation only, even though we could make more multiplications to have better accuracy.
Thank you for watching!
4355679 Bytes