Skip to main content

Half adder/subtractor; 1's and 2's complement subtraction

Short answer

One XOR gate gives sum and difference S=D=A⊕B; carry C=AB, borrow Bo=A'B using two AND and one NOT. (a) 47-26: 47=00101111, 2's comp of 26=11100110; sum=1 00010101, discard end carry, result = 21. (b) 10010-10011: 1's comp of 10011=01100; sum=11110, no end-around carry, result = -00001 = -1.

Design half adder and half subtractor in a single circuit. Perform following operation: a) (47)₁₀ - (26)₁₀ subtraction using 2's complement method. b) (10010)₂ - (10011)₂ using 1's complement method.

Half adder and half subtractor in one circuit

Inputs AA, BB. Outputs: sum SS, carry CC, difference DD, borrow BoB_o (A−BA - B).

ABSCDBoB_o
000000
011011
101010
110100
S=D=A⊕B,C=AB,Bo=A′BS = D = A \oplus B, \qquad C = AB, \qquad B_o = A'B

The sum and difference are the same function, so one XOR gate serves both. Add one AND gate for CC and one NOT plus one AND gate for BoB_o.

A --+---------------[XOR]------> S (= D)
B --|--+------------[   ]
    |  |
    +--|------------[AND]------> C
    |  +------------[   ]
    |  |
    +--|--[NOT]--A'-[AND]------> Bo
       +------------[   ]

Total: 1 XOR, 2 AND, 1 NOT.

(If one output pair with a mode input MM is preferred: S/D=A⊕BS/D = A \oplus B, C/Bo=(A⊕M)BC/B_o = (A \oplus M)B, giving carry when M=0M=0 and borrow when M=1M=1.)

a) (47)₁₀ − (26)₁₀ by 2's complement (8-bit)

47=0010 111126=0001 10102’s complement of 26=1110 0101+1=1110 0110\begin{aligned} 47 &= 0010\,1111 \\ 26 &= 0001\,1010 \\ \text{2's complement of } 26 &= 1110\,0101 + 1 = 1110\,0110 \end{aligned}
    0010 1111   (+47)
  + 1110 0110   (-26)
  -----------
  1 0001 0101

An end carry occurs: discard it. The result is positive.

Answer: 0001 01012=16+4+1=210001\,0101_2 = 16 + 4 + 1 = 21. Check: 47−26=2147 - 26 = 21.

b) (10010)₂ − (10011)₂ by 1's complement

1’s complement of 10011=01100\text{1's complement of } 10011 = 01100
   10010
 + 01100
 -------
   11110   (no end-around carry)

No end carry, so the result is negative; take its 1's complement:

11110‾=00001\overline{11110} = 00001

Answer: (10010)2−(10011)2=−(00001)2=−1(10010)_2 - (10011)_2 = -(00001)_2 = -1. Check: 18−19=−118 - 19 = -1.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Digital Logic chapter 5 questions →