30 Two’s-Complement (8-bit) Problems with Solutions

20 subtraction • 5 addition • 5 conversion/interpretation — with compact step-by-step work

A) Subtraction (20 problems)

  1. 1) 25 − 10
    25 = 00011001, 10 = 00001010. Compute 25 + (−10). −10: invert 0000101011110101, +1 → 11110110.
    00011001
    +11110110
    =00001111
    +15
  2. 2) 10 − 25
    10 = 00001010, 25 = 00011001. −25 = 11100111.
    00001010
    +11100111
    =11110001
    −15
  3. 3) 50 − 20
    50 = 00110010, −20 = 11101100.
    00110010
    +11101100
    =00111110
    +30
  4. 4) 20 − 50
    20 = 00010100, −50 = 11001110.
    00010100
    +11001110
    =11100010
    ?
  5. 5) 100 − 40
    100 = 01100100, −40 = 11011000.
    01100100
    +11011000
    =00111100
    ?
  6. 6) 40 − 100
    40 = 00101000, −100 = 10011100.
    00101000
    +10011100
    =11000100
    ?
  7. 7) 70 − 25
    70 = 01000110, −25 = 11100111.
    01000110
    +11100111
    =00101101
    ?
  8. 8) 25 − 70
    25 = 00011001, −70 = 10111010.
    00011001
    +10111010
    =11010093
    ?
  9. 9) −30 − 20
    −30 = 11100010, −20 = 11101100.
    11100010
    +11101100
    =11001110
    ?
  10. 10) −20 − (−30)
    −20 = 11101100, +30 = 00011110.
    11101100
    +00011110
    =00001010
    ?
  11. 11) 15 − 60
    15 = 00001111, −60 = 11000100.
    00001111
    +11000100
    =11010011
    ?
  12. 12) 60 − 15
    60 = 00111100, −15 = 11110001.
    00111100
    +11110001
    =00101101
    ?
  13. 13) 80 − 40
    80 = 01010000, −40 = 11011000.
    01010000
    +11011000
    =00101000
    ?
  14. 14) 40 − 80
    40 = 00101000, −80 = 10110000.
    00101000
    +10110000
    =11011000
    ?
  15. 15) −100 − 20
    −100 = 10011100, −20 = 11101100.
    10011100
    +11101100
    =10001000
    ?
  16. 16) 20 − (−100)
    20 = 00010100, +100 = 01100100.
    00010100
    +01100100
    =01111000
    ?
  17. 17) −50 − (−50)
    −50 = 11001110, +50 = 00110010.
    11001110
    +00110010
    =00000000
    0
  18. 18) −128 − 1
    −128 = 10000000, −1 = 11111111.
    10000000
    +11111111
    =01111111
    Overflow (true result −129 not representable)
  19. 19) 127 − (−1)
    127 = 01111111, +1 = 00000001.
    01111111
    +00000001
    =10000000
    Overflow (true result +128 not representable)
  20. 20) −60 − (−70)
    −60 = 11000100, +70 = 01000110.
    11000100
    +01000160
    =00001010
    +10

B) Addition (5 problems)

  1. 21) 25 + 30
    00011001
    +00011110
    =00110111
    +55
  2. 22) 50 + (−25)
    00110010
    +11100111
    =00011001
    +25
  3. 23) −40 + (−50)
    11011000
    +11001110
    =10100110
    ?
  4. 24) 90 + 60
    01011010
    +00111100
    =10010110
    Overflow (true result +150 not representable)
  5. 25) −128 + (−1)
    10000000
    +11111111
    =01111111
    Overflow (true result −129 not representable)

C) Conversion / Interpretation (5 problems)

  1. 26) Convert +45 to 8-bit two’s complement
    Decimal 45 → binary 00101101
  2. 27) Convert −45 to 8-bit two’s complement
    45 = 00101101 → invert 11010010 → +1 → ?
  3. 28) Interpret 11110110
    Negative → invert 00001001 → +1 00001010 = 10 → −10
  4. 29) Interpret 10000000
    Special case → min value → −128
  5. 30) Interpret 01100101
    MSB 0 → positive → 64+32+4+1 = 101