one point though, in two's complement, a negative binary number is first converted to positive, and then a 1 is added to the rightmost bit. The code you rephrased does not add a one to the rightmost bit of the result:
int count;
int num = 0;
for (count = 0; count < SIZE; ++count)
{
num *= 2; // shift left.
num += (binary[count] == '1')? 0 : 1;
} // end for
George N. Bilios
|