#include <iostream>
#include <cstdlib>
#include <string>
#include <cmath>
usingnamespace std;
int main()
{
string bin;
// double dec = 0; // decimal or "floating point" number are in IEEE representation this won't work unless the binary string is the full 64 bits and appropriately constructed
longlong dec = 0; // could use char, short, int, etc depending on the size of the string entered
cin >> bin;
for(int counter = 0; counter < bin.size(); counter++)
if(bin.at(counter) == '1') // don't know why you'd output a const cstring before taking the index? this is preferred.
{
dec += pow(2.0,double(bin.size() - 1 - counter)); // we're starting on the left-hand (most significant) side of the string
}
cout << dec << endl; // this will always be calculated as unsigned
return 0;
}