Consider a system that uses 5 bits for representing signed integers in 2’s…
2024
Consider a system that uses 5 bits for representing signed integers in 2’s complement format. In this system, two integers 𝐴 and 𝐵 are represented as 𝐴=01010 and 𝐵=11010. Which one of the following operations will result in either an arithmetic overflow or an arithmetic underflow?
- A.
A + B
- B.
A - B
- C.
B - A
- D.
2 * B
Attempted by 461 students.
Show answer & explanation
Correct answer: B
Key insight: determine the decimal values, check each arithmetic result against the 5-bit two's complement range (−16 to +15).
Convert the operands: A = 01010 = +10, B = 11010 = −6.
Check A − B: 10 − (−6) = 16. This exceeds the maximum representable +15, so it causes an arithmetic overflow. A 5-bit wrap gives 10000, which corresponds to −16, demonstrating the overflow.
Other operations do not overflow: A + B = 4 (00100), B − A = −16 (10000) which is representable, and 2 * B = −12 (10100).
Therefore, the operation that results in arithmetic overflow is A − B.
A video solution is available for this question — log in and enroll to watch it.