I try to convert any number base from 10 base. After I multiply two numbers that the same base, but the function should be recursive.
double convert(int number,int base)
{
int digit = 1;
double sum=0;
int i=0;
int figure;
double end;
if(base==10)
return number;
else
{
figure = (digit % (digit * 10) - number % digit) / digit;
end=pow(base,i);
sum+=figure*end;
++i;
digit *= 10;
convert(figure,base);
}
return sum;
}
But I'm confused in else, it doesn't work. How can I fix it? Any offers? Thanks..