1-bit binary subtraction (borrow logic): Compute 1 − 1 and report the difference and borrow.

Difficulty: Easy

Correct Answer: difference = 0 borrow = 0

Explanation:


Introduction / Context:
Single-bit subtraction defines core behavior for multi-bit subtractors. When the minuend bit equals the subtrahend bit and no prior borrow exists, the result is straightforward.


Given Data / Assumptions:

  • Subtracting a = 1 by b = 1.
  • No incoming borrow (borrow_in = 0).


Concept / Approach:
For one bit: difference = a xor b xor borrow_in; borrow_out = (~a & b) | ((~a | b) & borrow_in). With a=b=1 and borrow_in=0, difference=0 and borrow_out=0.


Step-by-Step Solution:

Compute difference: 1 xor 1 xor 0 = 0.Compute borrow: (~1 & 1) | ((~1 | 1) & 0) = (0 & 1) | (1 & 0) = 0.Report: difference 0, borrow 0.


Verification / Alternative check:
Decimal view: 1 − 1 = 0 with no need to borrow.


Why Other Options Are Wrong:

Any nonzero difference/borrow contradicts the computation.


Common Pitfalls:
Forgetting to specify borrow_in assumptions.


Final Answer:
difference = 0 borrow = 0

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion