Discussion
Consider a system that uses 5 bits for representing signed integers in 2’s complement format. In this system, two integers \(A\) and \(B\) are represented as \(A\)=01010 and \(B\)=11010. Which one of the following operations will result in either an arithmetic overflow or an arithmetic underflow?
Answer: B
The operation that overflows is \(A - B\).
Five-bit two's complement represents −16 to +15. A = 01010 = +10, and B = 11010 = 26 − 32 = −6. Then:
- A + B = 10 − 6 = 4: in range
- A − B = 10 + 6 = 16: above +15, overflow
- B − A = −6 − 10 = −16: exactly the most negative value, in range
- 2 * B = −12: in range
So only A − B leaves the representable range. The trap is B − A: −16 looks extreme but is representable as 10000, because two's complement has one more negative value than positive.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development