Professional Documents
Culture Documents
Discussion Unit 3 - With Answer
Discussion Unit 3 - With Answer
In your implementation of the ALU there is no need to detect or handle overflow. However, it's
a good mental exercise to think about when/how an overflow might occur. When adding
numbers with different signs, overflow cannot occur because the sum must be no larger than one
of the numbers.
What happens when the signs of the numbers are the same?
If 2 Two's Complement numbers are added, and they both have the same sign (both
positive or both negative), then overflow occurs if and only if the result has the
opposite sign. Overflow never occurs when adding operands with different signs.
Overflow occurs if
(+A) + (+B) = −C
(−A) + (−B) = +C
If 2 Two's Complement numbers are subtracted, and their signs are different, then
overflow occurs if and only if the result has the same sign as the subtrahend.
Overflow occurs if
(+A) − (−B) = −C
(−A) − (+B) = +C
Alternative approach: Overflow can be identified and detected using a different mechanism, but, of
course, keeping intact the fundamental requirements as mentioned above in conclusions (1) and (2).
This means that overflow may occur if the two numbers being added are of the same sign. Numbers
having different sign when added will not give rise to any overflow, because the result after addition
will produce a result which will be always smaller than the larger of the two original numbers. To
explain and exhibit the overflow, consider the following examples of 8-bit addition, as shown in
Figure 7.3, with 8-bit signed integers in 2's complement form in which the most significant bit in
each binary number is the sign bit. (ebrary)
Reference
https://www.doc.ic.ac.uk/~eedwards/compsys/arithmetic/index.html
https://ebrary.net/206259/computer_science/addition_subtraction_signed_numbers