So I kind of want to make a basic base conversion program just for the hell of it. I'm not really sure how to go about doing it though. I can convert a number of any base to any other base just fine on paper, just not sure how to do it in a program.
1) Explain, in very simple step-by-step instruction form, the process of how you do it on paper
2) Translate that explanation into C++ code.
3) ???
4) Profit
Well, with how I do it on paper, I feel like I'd have to pick apart a string representation of a number first. Here's how I do it:
From base 10 to octal for example:
8526 / 8 = 1065 remainder 6
1065 / 8 = 133 remainder 1
133 / 8 = 16 remainder 5
16 / 8 = 2 remainder 0
2 / 8 = 0 remainder 2
So, 8526 base 10 = 20516 base 8
Base 10 to base x is simple enough. But base x to base 10 seems complicated to me, here's how I do it:
For simplicity, we'll use binary to base 10, but the method stays the same through out.
11010011 to base 10
Starting from the 2^0 bit, I move to the left till Im out of digits.