Perform the indicated operation of the numbers, which are in two's-complement representation. Check your results by converting all numbers to decimal. Indicate overflow and carryout.
(a) 10010111-00111100
1001 0111 (151)
- 0011 1100 (60) ---->+ 1100 0100 (-60)
- I used two's complement to change (60) to (-60).
10010111 (151)
+ 11000100 (-60)
= 1 0101 1011
- The answer is in 9 bits, while the rest are in 8 bits.
- The range is -128 to 127 : -(2^(8-1)) to (2^(8-1)-1)
Is this a carry out? Is this an overflow? I know that it's a carry out because we are adding a bit into the sign. But is this considered an overflow? Discarding the 1 on the left-most side, we convert the answer to (91) in decimal, which matches with (151) - (60) = (91).
I at first considered this NOT an overflow, because (91) is in range. However, I am not sure if I am supposed to take into account the carry out of 1. The 1 also confuses me because the answer is positive and not negative. Am I supposed to discard the 1? Is this signed, meaning that the answer is negative? But the answer is supposed to be positive?? I'm just getting a little more confused the more I think about it.
(I know I could have just subtracted normally, but I wanted to do it this way)