Logic circuits

When adding two's complement numbers, which condition indicates that an overflow has occurred?

  1. AWhen the carry into the most significant bit differs from the carry out of the most significant bit
  2. BWhen the result is 0
  3. CWhen the sum of the least significant bits is 1
Show answer and explanation

Answer: A. When the carry into the most significant bit differs from the carry out of the most significant bit

In two's-complement addition, overflow occurs when two positives yield a negative or two negatives yield a positive, detected when the carry into the top bit differs from the carry out of it (their XOR is 1). For example, in 4 bits 0111 (7) + 0001 (1) = 1000 (−8). Adding numbers of opposite sign can never overflow. Many CPUs report this in a dedicated flag (the V flag on Arm and others, OF on x86), distinct from the carry flag for unsigned carry-out (C or CF).

  • A. Correct. Overflow is when the carries into and out of the MSB differ.
  • B. A result of 0 does not indicate overflow.
  • C. The least significant bit is irrelevant to overflow detection.

Related calculators

Books on Logic circuits Ad

Learn hands-on: parts and kits

Building real circuits is a good way to check what you learned in the questions.

As an Amazon Associate I earn from qualifying purchases.

More Logic circuits questions

  1. How many states does a Johnson (twisted-ring) counter made of n flip-flops go through?
  2. What is a typical use of a linear feedback shift register (LFSR), which feeds the XOR of some outputs of a shift register back to its input?
  3. When several open-drain outputs are connected to one signal line with a pull-up resistor, how does the line behave?
  4. When is the output of a two-input NAND gate 0?
  5. According to De Morgan's laws, which expression is equal to NOT(A AND B)?

Comparisons in this topic