In the following code I am converting a binary to decimal and then printing the character corresponding to it.
void convertToChar(int binaryChar[],int length)
{
int multiplier = 0;
int i;
int sum = 0;
for(i=length;i>=0;i++)
{
sum = sum + (binaryChar[i]*pow(2,multiplier));
multiplier = multiplier + 1;
}
printf("\nThe character is: %c",sum);
}
The problem is in the line sum = sum + (binaryChar[i]*pow(2,multiplier)); .It throws the error: warning: converting toint' from double'.Please help!
pow(2,..), use bitwise arithmetic, it's faster and cleaner. (the reason you're getting complaints about doubles is becausepow()uses double as arguments and return value.