I'm studying for an upcoming exam and found this question in the guide:
Assuming the use of an 8 bit binary adder for twos complement binary number encoding, what is the result of adding FF and 01 (in hexadecimal)?
And the options are (I can only select one):
1. 0 (In decimal)
2. 100 (In hexadecimal)
3. Cannot represent result due to bit overflow
4. 256 (in decimal)
My logic tells me that both 2 and 4 are correct since the operation would result in adding
1111 1111
0000 0001
---------
1 0000 0000
Which is 256 in decimal or 100 in hex, but the correct answer is 1. 0 (decimal), how did they arrive at that conclusion, is the final carry bit just ignored entirely? If it is then why doesn't it cause an overflow?
I think "overflow" is normally defined in terms of whether the result makes sense, not whether some bit happens to fall off the edge in the process.
You are adding 1 to -1, and the result is 0. Everything is in range; there is no overflow.
Overflow would have been if you added, say, 127 and 1. That should yield 128, but since we're dealing with 8-bit two's complement, you will get -128 instead. That would be overflow.
Digression: One might argue that the question is badly posed because the number FF (decimal 255) cannot be represented in 8-bit twos complement, where the range is -128 to 127, inclusive. However, it is quite common that hex numbers are used to show bit patterns, regardless of what those bit patterns actually mean, and the bit pattern "all bits set" would mean -1.