I'm using netBean to code C, and my assignment is convert a very large binary number to decimal ( the binary number maybe upto 100 digits), I'm very confuse because my program works when the binary number is about 50-60 digits but it will automatically crash on run-time when input is larger. I'm using long long int to store the decimal result but it seem doesn't work! Here is my code :
long long int decimal = 0;
int position = 0;
for(int i = strlen(binaryInput)-1; i>=0; --i){
if(binaryInput[i]=='1'){
decimal += (long long int)(pow(2,position));
}
++position;
}
printf("\nDecimal number is: %lli ", decimal);
'binaryInput' is my string to store binaryNumber from keyboard.