curious_kid
curious_kid

Reputation: 399

Signed Overflow - Why carry in and carry out of MSB should match?

In binary addition of two signed integers if the carry in and out of the MSB column doesn't match then there is a signed overflow.

What is the logic behind this rule. Why carry in and carry out should match to get the correct result. Please Explain.

Upvotes: 3

Views: 3914

Answers (1)

Jester
Jester

Reputation: 58762

Obviously two cases for a mismatch:

  1. There was carry in but no carry out. This must mean both input MSBs were 0, but result MSB is 1. Since MSB is the sign bit, this corresponds to adding two non-negative numbers and getting a negative result, thus overflow.
  2. There was no carry in but there is carry out. This must mean both input MSBs were 1, but result MSB is 0. This corresponds to adding two negative numbers becoming non-negative, thus overflow.

Upvotes: 5

Related Questions