Computer Organization & Architecture
Memory Hierarchy & Floating Point
GATE 2019
Hard
Consider Z = X − Y, where X, Y and Z are all in sign-magnitude form. X and Y are each represented in n bits. To avoid overflow, the representation of Z would require a minimum of:
- An bits
- Bn − 1 bits
- n + 1 bits
- Dn + 2 bits
Explanation
The largest magnitude representable in n-bit sign-magnitude is 2^(n-1)−1. In the worst case, X=+(2^(n-1)−1) and Y=−(2^(n-1)−1), giving Z=X−Y=2(2^(n-1)−1)=2^n−2. Representing a magnitude up to 2^n−2 needs n magnitude bits (since 2^(n-1)≤2^n−2<2^n), plus 1 sign bit = n+1 bits total.
Source: GATE CS 2019 (Set-2) (2019)
This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.