Question
Let be the number of distinct 16-bit integers in 2's complement representation. Let be the number of distinct 16-bit integers in sign magnitude representation.
Then is ________.
Official answer and solution
- Official answer
- 1
- From
- Official GATE 2016 answer key
Solution
Count the number of distinct integers representable in 16-bit 2's complement and sign-magnitude representations.
- 16-bit 2's complement representation:
- The range of representable integers is .
- In 2's complement, every bit pattern represents a unique integer (zero has a single representation ).
- Number of distinct integers: .
- 16-bit sign-magnitude representation:
- The range of representable integers is .
- Zero has two representations: () and ().
- Number of distinct integers: .
- Calculate the difference:
Thus, .
Final answer
1
Common trap
Thinking sign-magnitude has 2 fewer numbers instead of 1 (due to the single redundant representation of zero).
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2016 Computer Science and Information Technology (CS) Session 2
- Question
- 19 of 65, printed as CS Q.9
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.