Exercise 2: Checking -3 - 2 for Overflow — Possible Solution ==================================================================== GIVEN ------------------------------ A = -3, B = 2, M = 1 (subtraction mode) STEP 1: ENCODE THE OPERANDS ------------------------------ A = -3 in 3-bit two's complement: 101 B = 2 in 3-bit two's complement: 010 B XOR M (M=1, so B is bit-inverted): 101 STEP 2: TRACE EACH FULL-ADDER STAGE ------------------------------ LSB: full_adder(A=1, Bmod=1, cin=1) -> SUM=1, COUT=1 middle: full_adder(A=0, Bmod=0, cin=1) -> SUM=1, COUT=0 sign/MSB: full_adder(A=1, Bmod=1, cin=0) -> SUM=0, COUT=1 STEP 3: ASSEMBLE THE RESULT ------------------------------ Result bits: 011 -> decimal 3 STEP 4: CHECK OVERFLOW ------------------------------ Carry into sign stage (from middle stage): 0 Carry out of sign stage: 1 Overflow = 0 XOR 1 = 1 -> OVERFLOW DETECTED RESULT ------------------------------ The circuit reports a raw result of 3, but this chapter's own overflow formula flags it as unreliable. Checking directly: the true mathematical answer to -3 - 2 is -5, which falls outside the 3-bit signed range (-4 to 3, per Chapter 9) - so the reported "3" is a wraparound artifact, not the correct answer. The overflow flag is doing exactly its job here: correctly warning that this particular result cannot be trusted. WHY THIS WORKS AS AN ANSWER ------------------------------ Both operands are encoded correctly (including A's own negative value), every stage of the circuit is traced explicitly, and the overflow flag's own correctness is independently confirmed by computing the true mathematical answer (-5) and confirming it genuinely falls outside the representable range - not just trusting the formula's output without checking it against reality.