Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 1 — Half Subtractor and Full Subtractor

Lesson 12 of 49 in the free Computer Organization and Architecture notes on Siksha Sarovar, written by Rohit Jangra.

Subtractors

A subtractor computes A − B in binary, producing a difference and a borrow.

1. Half Subtractor

Subtracts two bits: A − B. Note that the order matters — subtraction is not commutative.

Truth table

ABDifference (D)Borrow (Bout)
0000
0111
1010
1100
Row 2 explains everything: 0 − 1 requires borrowing 1 from the next higher position, which makes the local computation 10 − 1 = 1. Hence D = 1, Borrow = 1.

Boolean equations

   D    = A'B + AB' = A ⊕ B         (same as the half-adder sum!)
   Bout = A' . B                    (borrow only when A=0 and B=1)

Compare with the half adder: the sum/difference expressions are identical; only carry (A·B) vs borrow (A'·B) differ. A half subtractor is a half adder with one inverter added on A before the AND gate.

2. Full Subtractor

Subtracts three bits: A − B − Bin, where Bin is the borrow from the previous (less significant) stage.

Truth table

ABBinDifference (D)Borrow out (Bout)
00000
00111
01011
01101
10010
10100
11000
11111
   D    = Σm(1, 2, 4, 7)      <- identical to the full-adder SUM
   Bout = Σm(1, 2, 3, 7)

K-map for Difference

              B Bin
         00     01     11     10
       +------+------+------+------+
   A=0 |  0   |  1   |  0   |  1   |
       +------+------+------+------+
   A=1 |  1   |  0   |  1   |  0   |
       +------+------+------+------+

   Checkerboard -> D = A ⊕ B ⊕ Bin

K-map for Borrow-out

              B Bin
         00     01     11     10
       +------+------+------+------+
   A=0 |  0   |  1   |  1   |  1   |
       | (0)  | (1)  | (3)  | (2)  |
       +------+------+------+------+
   A=1 |  0   |  0   |  1   |  0   |
       | (4)  | (5)  | (7)  | (6)  |
       +------+------+------+------+

   Group m1, m3  ->  A'.Bin
   Group m2, m3  ->  A'.B
   Group m3, m7  ->  B.Bin

   Bout = A'B + A'.Bin + B.Bin
        = A'B + Bin(A ⊕ B)'      <- alternative form
        = A'B + Bin(A' + B) ... standard exam answer is the first form

Full subtractor from two half subtractors

   HS1:  D1   = A ⊕ B            B1 = A' . B
   HS2:  D    = D1 ⊕ Bin         B2 = D1' . Bin
   Then: Bout = B1 + B2 = A'B + (A ⊕ B)'.Bin

3. Adder vs Subtractor — Side by Side

QuantityFull AdderFull Subtractor
Third inputCarry-inBorrow-in
Sum / DifferenceA ⊕ B ⊕ CinA ⊕ B ⊕ Bin
Carry / BorrowAB + Cin(A ⊕ B)A'B + Bin(A ⊕ B)'
Difference in hardwareOne inverter on A, and the XOR feeding the second AND is complemented

4. Worked Numerical

   Compute 1011 - 0110 using four full subtractors (Bin of the LSB = 0).

   Position:      3    2    1    0
   A:             1    0    1    1
   B:             0    1    1    0

   Stage 0: A=1 B=0 Bin=0  ->  D=1, Bout=0
   Stage 1: A=1 B=1 Bin=0  ->  D=0, Bout=0
   Stage 2: A=0 B=1 Bin=0  ->  D=1, Bout=1
   Stage 3: A=1 B=0 Bin=1  ->  D=0, Bout=0

   Difference = 0101 = 5      Check: 11 - 6 = 5  ✓  Final borrow 0 -> positive result

5. Why Real Machines Do Not Build Subtractors

Building a separate subtractor doubles the arithmetic hardware. Real ALUs use 2's complement:

   A - B  =  A + (2's complement of B)
          =  A + B' + 1

A single adder plus a row of XOR gates does both operations — that is the parallel adder/subtractor of the next lesson, and it is the standard answer to "how does a computer subtract?"

6. Practice

   1. Design a half subtractor using NAND gates only.
      D = A ⊕ B      -> 4 NAND
      Bout = A'B     -> NOT A (1 NAND) then AND (2 NAND) = 3 NAND
      Total = 7 NAND (sharing the inverter reduces this)

   2. Verify the full subtractor for A=0, B=1, Bin=1  (0 - 1 - 1 = -2)
      D    = 0 ⊕ 1 ⊕ 1 = 0
      Bout = A'B + Bin(A⊕B)' = 1.1 + 1.(1)' = 1 + 0 = 1
      Reading "Bout D" as -(2) + 0 -> borrow 1, difference 0
      i.e. 0 - 1 - 1 = 10(2) borrowed, difference 0  ✓

Next: cascade these single-bit cells into a full n-bit parallel adder/subtractor, and see why the carry chain is the speed limit of the whole CPU.