Hex to Decimal, call of overload error

Oct 18, 2010 at 7:18pm
on this line of my program:

sum=sum+(b[i]*pow(16,j));

the complier gives me a message that reads "call of overload 'pow(int, int&) is ambiguous. i have no idea what this error means so can someone help me? this program converts numbers to other forms, and this is in the hex to decimal part. here is the rest of the hex to decimal section of code:

case 4:
{
int n,i,j,b[100],sum=0;
char a[100];
cout<<"Enter number of digits in your hexadecimal number: ";
cin>>n;
cout<<"Enter hexadecimal number one character at a time: ";
for(i=1;i<=n;i++)
{
cin>>a[i];
}
for(i=1;i<=n;i++)
{
if(a[i]=='0')
{
b[i]=0;
}
if(a[i]=='1')
{
b[i]=1;
}
if(a[i]=='2')
{
b[i]=2;
}
if(a[i]=='3')
{
b[i]=3;
}
if(a[i]=='4')
{
b[i]=4;
}
if(a[i]=='5')
{
b[i]=5;
}
if(a[i]=='6')
{
b[i]=6;
}
if(a[i]=='7')
{
b[i]=7;
}
if(a[i]=='8')
{
b[i]=8;
}
if(a[i]=='9')
{
b[i]=9;
}
if(a[i]=='A'||a[i]=='a')
{
b[i]=10;
}
if(a[i]=='B'||a[i]=='b')
{
b[i]=11;
}
if(a[i]=='C'||a[i]=='c')
{
b[i]=12;
}
if(a[i]=='D'||a[i]=='d')
{
b[i]=13;
}
if(a[i]=='E'||a[i]=='e')
{
b[i]=14;
}
if(a[i]=='F'||a[i]=='f')
{
b[i]=15;
}
}
j=n-1;
for(i=1;i<=n;i++)
{
sum=sum+(b[i]*pow(16,j));
j--;
}
cout<<"The number in decimal is "<<sum<<endl;
}
break;
Oct 18, 2010 at 8:14pm
sum = sum + (b[i] * pow(16, static_cast<double> (j)));
Oct 18, 2010 at 8:34pm
thank you so much :) it works like a charm now
Topic archived. No new replies allowed.