can someone look at this? in theory it should work but i cant figure it out
thanks in advance
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
void binToDec(string getBinary);
int main()
{
string getBinary;
cout<<"Enter a Binary Number:"<<endl;
cin>>getBinary;
binToDec(getBinary);
return 0;
}
void binToDec(string getBinary)
{
int setLength,total=0;
double placeholder=0;
setLength=getBinary.size();
for(int i=setLength;i>0;i--)
{
int num=pow(2.0,placeholder);
int test=getBinary[i];
if (test==1)
{
total=total+num;
}
placeholder=placeholder +1;
}
cout<<total<<endl;
}