I have come across a pretty neat algorithm to convert a decimal number to other number systems. program asks for two inputs: number to convert and the base. the output is the number in the base required.
I am wondering if there is possible a single algorithm to convert an octal number to the base of choice?
I have come across a pretty neat algorithm to convert a decimal number to
Share
Of course it is possible. Any number in any base can be written in any other base. For example, it is pretty easy to convert base 8 to base 2, just go one by one from the back and write each number in base 2 using length 3 (this works because 8 = 2^3), e.g.
I bet the same algorithm you use to convert from base 10 to other bases can be easily modified to base 8.