Subtraction with two's complement
8-bit method
To calculate A − B: represent A and B on 8 bits, compute C2(B), then perform A + C2(B). Discard any carry beyond 8 bits and interpret the result as signed.
Example: 25 − 37
A = 00011001
B = 00100101
Invert B → 11011010
+1 → 11011011
00011001+11011011=11110100
Signed result: -12.
Practice
Progress: 0 / 5 — correct: 0
Calculate using 8 signed bits: 23 − -11
23=00010111; -11=11110101; invert the second value: 00001010; +1: 00001011; add on 8 bits: 00100010.
Overflow
With 8 signed bits the result must remain between −128 and +127. A result outside that range causes overflow.