If the user inputs a very large number in binary the output shows a 0, how would I go about modifying this function to work with larger numbers?
{
// Binary to Decimal converter function
int bin_Dec(int myInteger)
{
int output = 0;
for(int index=0; myInteger > 0; index++ )
{
if(myInteger %10 == 1)
{
output += pow(2, index);
}
myInteger /= 10;
}
return output;
}
int _tmain(int argc, _TCHAR* argv[])
{ // start main
int myNumber;
// get number from user
cout << "Enter a binary number, Base2: "; // ask for number
cin >> myNumber;
//print conversion
cout << "Base10: " << bin_Dec(myNumber) << endl; // print conversion
system("pause");
} // end of main
}