Proof: when summing a positive and negative number, why can't the sum be larger than one of the operands?

36 Views Asked by At

In my computer hardware/architecture textbook, there's a section on computer arithmetic and overflow. The text says:

When adding operands with different signs, overflow cannot occur. The reason is the sum must be no larger than one of the operands. For example, -10 + 4 = -6.

So it's saying that the sum is always trapped between the two operands. How would I go about proving this? For example:

  • $a > 0$

  • $b < 0$

  • $a + b ?$

2

There are 2 best solutions below

1
On BEST ANSWER

If $a>0$ then $a+b>b$ for any $b$ (we see this by adding $b$ to both sides).

If $0>b$ then $a>a+b$ for any $a$ (add $a$ to both sides to see this).

If $a>0$ and $0>b$, these two facts combine to make $a>a+b>b$.

0
On

$a > 0$, $b< 0$ then

$a + b = |a| - |b| < |a|= a$ and $a+b = |a| - |b| > -|b| = b$.

So $b < a + b < a$.