Note: Just tell me if my reasoning or logic is wrong.
So I have two numbers 01001 and 1110. And the question asks to subtract them as both signed and unsigned system.
Unsigned System
For this I can use, subtraction via addition (2's compliment system).
Question: 01001 - 1110 1110 -> 01110 // Sign extension 01110 -> 10001 // Inverting Bits 10001 + 1 -> 10010 // Adding one Now, 01001 10010 + ----- 11011 From my book it says, "No final carry in step 2 indicates a final borrow, or a greater “2nd number” than the “1st number”, hence an impossible subtraction." So I concluded Overflow generated and borrow occurred as the second number is greater than first number.
Signed System
Question: 01001 - 1110 1110 -> 11110 // Sign extension Now, Carry:1 1 000 0 1001 1 1110 + ------- 0 0111 The book says, "In 2’s complement subtraction modeled by Equation (7), and also in 2’s complement addition, overflow occurs if and only if the carry bit arriving at the sign column is different from the carry bit leaving this column." Hence, No overflow and borrow occurred.
Is there anything I left or didn't consider? For some reason I feel like I messed up signed part even though the result makes sense. 9 -2 = 7