Converting bases

Hello, I have researched the areas of the forums as much as I can to learn information on my topic. My project is I need to make a program where I input a number between 2 and 16 inclusive and that is my starting base. next I input a binary number, after that I input any other number between 2 and 16 again and it will convert it into that base. So I understand I need to convert my binary number into a decimal and then back to binary into the base that I input, but I have no idea how to write that as code, I don't even know where to begin. I am very new and c++ makes little sense to me. I appreciate any and all help.
I think you have a bit of terminology confusion. Binary is base 2. Other bases are not binary.

Think about how numbers are stored in base 10:
1234.56 = 1000 + 200 + 30 + 4 + .5 + .06
= 1*103 + 2*102 + 3*101 + 4*100 + 5*10-1 + 6*10-2

See any patterns?
I see the patterns but I don't understand how it applies? If this helps, an example input of my program has to be 3 1001011 4 5

3 is my starting base of the 1001011. The program is supposed to convert it to decimal and into base 4 and 5 then print it on the screen.
1001011 is a valid base-3 number, but it looks more like binary because there are no 2s. I still think you are misunderstanding the assignment.
I understand the assignment, its pretty straightforward. Take a binary number of a certain base, and convert it to binary of a different base. But to do that i have to convert it to decimal, and then back to binary.
Galvanized wrote:
Take a binary number of a certain base, and convert it to binary of a different base.
Binary is base 2. Other bases are not binary.
> into base 4 and 5

into two different bases ?
Topic archived. No new replies allowed.