Fiveable

🔌Intro to Electrical Engineering Unit 15 Review

QR code for Intro to Electrical Engineering practice questions

15.4 Adders and subtractors

15.4 Adders and subtractors

Written by the Fiveable Content Team • Last updated August 2025
Written by the Fiveable Content Team • Last updated August 2025
🔌Intro to Electrical Engineering
Unit & Topic Study Guides

Adders and subtractors are the building blocks that let digital circuits do math. They handle binary addition and subtraction, starting from simple single-bit operations and scaling up to multi-bit arithmetic used in real processors.

Understanding how these circuits work gives you a clear picture of how computers process numbers at the hardware level, and why design choices like carry propagation matter for speed.

Adders

Half Adder and Full Adder

A half adder adds two single-bit binary numbers (AA and BB) and produces two outputs: a sum (SS) and a carry out (CC). It uses an XOR gate for the sum and an AND gate for the carry.

The Boolean expressions are:

  • S=ABS = A \oplus B
  • C=ABC = A \cdot B

Think of it this way: the XOR tells you the single-bit result, and the AND tells you whether the addition "overflowed" into the next column (just like carrying a 1 in decimal addition).

ABSC
0000
0110
1010
1101

The limitation of a half adder is that it has no input for a carry from a previous stage. That's where the full adder comes in.

A full adder adds three single-bit inputs: AA, BB, and a carry in (CinC_{in}). It produces a sum (SS) and a carry out (CoutC_{out}). Internally, you can build one from two half adders and an OR gate:

  1. The first half adder computes ABA \oplus B and ABA \cdot B.
  2. The second half adder adds CinC_{in} to the result of the first XOR.
  3. The OR gate combines the two carry outputs to produce CoutC_{out}.

The Boolean expressions are:

  • S=ABCinS = A \oplus B \oplus C_{in}
  • Cout=(AB)+(Cin(AB))C_{out} = (A \cdot B) + (C_{in} \cdot (A \oplus B))
ABCinSCout
00000
00110
01010
01101
10010
10101
11001
11111

Multi-bit Adders

To add numbers wider than one bit, you chain full adders together.

A ripple carry adder (RCA) is the simplest approach. You cascade nn full adders for an nn-bit addition, connecting the CoutC_{out} of each stage to the CinC_{in} of the next. For example, a 4-bit RCA uses four full adders in series.

The downside is speed. Each full adder has to wait for the carry from the previous stage before it can produce a valid output. The total delay grows linearly with the number of bits, so a 32-bit RCA is roughly 32 times slower than a single full adder. This is called carry propagation delay.

A carry look-ahead adder (CLA) solves this problem by computing carry signals in parallel rather than waiting for them to ripple through. It uses two intermediate signals for each bit position:

  • Generate (Gi=AiBiG_i = A_i \cdot B_i): a carry is produced at this stage regardless of the incoming carry.
  • Propagate (Pi=AiBiP_i = A_i \oplus B_i): an incoming carry will pass through this stage.

Using these signals, the CLA calculates all carry bits simultaneously with dedicated logic. For instance, C1=G0+P0C0C_1 = G_0 + P_0 \cdot C_0 and C2=G1+P1G0+P1P0C0C_2 = G_1 + P_1 \cdot G_0 + P_1 \cdot P_0 \cdot C_0, and so on. This is significantly faster than an RCA, but the trade-off is more complex hardware and more gates.

Half Adder and Full Adder, Sabirač (elektronika) — Википедија

Subtractors

Half Subtractor and Full Subtractor

A half subtractor subtracts one single-bit number (BB) from another (AA). It produces a difference (DD) and a borrow out (BoutB_{out}).

  • D=ABD = A \oplus B (same XOR as the half adder)
  • Bout=ABB_{out} = \overline{A} \cdot B (an AND gate with AA inverted)

The borrow output is 1 when A=0A = 0 and B=1B = 1, because you need to "borrow" from the next column, just like borrowing in decimal subtraction.

ABDBout
0000
0111
1010
1100

A full subtractor handles three inputs: AA, BB, and a borrow in (BinB_{in}) from a previous stage. It's built from two half subtractors and an OR gate, similar to how a full adder is built from half adders.

  • D=ABBinD = A \oplus B \oplus B_{in}
  • Bout=(AB)+(Bin(AB))B_{out} = (\overline{A} \cdot B) + (B_{in} \cdot \overline{(A \oplus B)})
ABBinDBout
00000
00111
01011
01101
10010
10100
11000
11111

In practice, dedicated subtractor circuits are rarely built. Instead, most systems use an adder combined with two's complement to perform subtraction, which means the same hardware handles both operations.

Half Adder and Full Adder, Adder (electronics) - Wikipedia

Arithmetic and Overflow

Two's Complement Arithmetic

Two's complement is the standard way digital systems represent signed (positive and negative) integers. Positive numbers look the same as regular binary. To represent a negative number:

  1. Start with the binary representation of the positive value.
  2. Invert all the bits (flip 0s to 1s and 1s to 0s).
  3. Add 1 to the result.

For example, in an 8-bit system, +5+5 is 00000101. To get 5-5: invert to get 11111010, then add 1 to get 11111011.

For nn bits, the representable range is 2n1-2^{n-1} to 2n112^{n-1} - 1. So an 8-bit system covers 128-128 to +127+127.

The big advantage of two's complement is that addition and subtraction use the same adder circuit. To subtract BB from AA, you just negate BB (invert and add 1) and then add it to AA. This is why most processors don't need separate subtractor hardware.

Overflow Detection

Overflow happens when the result of an arithmetic operation falls outside the representable range. In two's complement, this occurs when:

  • Adding two positive numbers gives a negative result, or
  • Adding two negative numbers gives a positive result.

Adding a positive number to a negative number can never overflow, because the result is always between the two operands.

The hardware detection method: compare the carry into the most significant bit (MSB) with the carry out of the MSB. If they differ, overflow has occurred. In Boolean terms, the overflow flag is:

V=Cin,MSBCout,MSBV = C_{in,MSB} \oplus C_{out,MSB}

For example, in a 4-bit system, adding 01110111 (+7) and 00010001 (+1) gives 10001000 (-8), which is clearly wrong. The carry into bit 3 is 1 and the carry out of bit 3 is 0, so V=1V = 1, flagging the overflow.

Detecting overflow matters because ignoring it leads to silently wrong results. Systems handle it in different ways: raising an exception, saturating to the max/min value, or setting a status flag for software to check.