- #1
Jkohn
- 31
- 0
Hey all, I am majoring in math and taking this c++ which I am having some trouble with. [Im into paper and pencils ]
So my assignment is to have a number saved in a string then convert it from a string to an integer (have that done) and finally convert that number to a decimal number from whatever base the user inputs.
I am lost with the int-base to decimal.
I was thinking using BASE 2 and convert it which ever base.
Integer--> convert it to base 2-->user inputs base-->converst BASE 2-->BASE N
Ex.
read 6
convert that to base 2-->110 [4+2+0=6]
user wants base 2-->print 110
Im assuming there is an algorithm for converting between bases that I don't know about.
Any ideas on how to do this and additional help would be really appreciated!
ty all!
So my assignment is to have a number saved in a string then convert it from a string to an integer (have that done) and finally convert that number to a decimal number from whatever base the user inputs.
I am lost with the int-base to decimal.
I was thinking using BASE 2 and convert it which ever base.
Integer--> convert it to base 2-->user inputs base-->converst BASE 2-->BASE N
Ex.
read 6
convert that to base 2-->110 [4+2+0=6]
user wants base 2-->print 110
Im assuming there is an algorithm for converting between bases that I don't know about.
Any ideas on how to do this and additional help would be really appreciated!
ty all!