I'm a little new to c++. I have written a code for a base conversion program. It handles base conversion between bases 2-36 and stops when the user enters "0". I have written the program, however I still need to make it convert whole numbers instead of just integers. Ex: 0.22 or 13.587 etc. I also need to be able to convert negative numbers. Can someone help me out?
Thanks in advance!
here is what I have so far.
int main()
{
int number,base,final[99];
double remainder;
cout<<"Enter the number system base (2--36): ";
cin>>base;
if( base<37&& base>1)
{
while (number !=0)
{
int i=0;
cout<<"Enter a decimal integer: ";
cin>>number;
if (number==0)
{
cout<<"bye!"<<endl;
break;
}
while (number !=0)
{
remainder=(number%base);
final[i]=remainder;
i++;
number=number/base;
}
for (i--; i>-1; i--)
{
if (final[i]<10)
cout<<final[i];
else
cout<<char(final[i]-10+'a');
}
number=1;
cout<<endl;
}
}
return 0;
}