Subtraction by two's complement: 1011 − 0110 — adders

exam standardone adder does both operations

Answer

0101

Why this example is worth doing

Invert the subtrahend, force the carry-in to 1, and the same adder subtracts. That is why processors have an adder and not a subtractor, and it is the payoff of the two's complement representation. The page shows the XOR gates that conditionally invert — the controlled-inverter identity from the XOR page — and links to the two's complement tool for the representation itself.

Try your own input in the Half adder & full adder. Truth tables, K-maps and circuits for both adders, and the ripple-carry chain.

How the answer is reached

1011 - 0110 (4-bit, unsigned)

1011 - 0110 (4-bit, unsigned) — columns operand, bits, hex, unsigned, signed
operandbitshexunsignedsigned
A10110xB11-5
B01100x666

Method A — borrow propagation.

The digit above column i is the carry or borrow into column i. Bit 0 is the least significant column. — 1011 - 0110
row3210
borrow in1000
A1011
- B0110
result0101

C = 0 · V = 1 · N = 0 · Z = 0

Method B — add the two’s complement of B, then discard the final carry.

NOT B1001

NOT B + 11010the two’s complement of B

The digit above column i is the carry or borrow into column i. Bit 0 is the least significant column. — 1011 + 1001
row3210
carry in0111
A1011
+ B1001
result0101

carry in 1 · carry out 1 (discarded)

reading the final carry1: no borrow, A >= B as unsigned

signed-5 - 6 = -11, kept as 5V = 1: the signed answer is wrong

Warning:

Both methods are shown because curricula grade different ones. The final carry of method B is always the complement of the borrow-out of method A.

Compare with

Open the Half adder & full adder

This input is entered in the tool itself — it is too rich for a link to carry.

Note:

Notation this page assumes

  • Symbols: · is AND, + is OR, ⊕ is XOR, a prime or an overline is NOT. The field also takes ∧ ∨ ¬ ~ ! & | and the words.
  • Operator precedence, tightest first: NOT, then AND (including juxtaposition), then XOR/XNOR, then NAND/NOR, then OR, then IMPLIES, then IFF.
  • Gate symbols follow whichever standard the header toggle is set to: ANSI/IEEE Std 91-1984 distinctive shapes, or IEC 60617-12 rectangles.

Sources

  • Shannon, “A Symbolic Analysis of Relay and Switching Circuits” (1938)
  • ANSI/IEEE Std 91-1984, Graphic Symbols for Logic Functions