edited by
12,179 views
34 votes
34 votes
Let $X$ be the number of distinct $16$-bit integers in $2's$ complement representation. Let $Y$ be the number of distinct $16$-bit integers in sign magnitude representation Then $X - Y$ is______.
edited by

4 Answers

Best answer
55 votes
55 votes

2's Complement Representation

The range of $n\text{-bit}\; 2$'s Complement Numbers is $-(2^{n-1})$ to $+(2^{n-1}-1)$

For example, if $n = 2$, then $-2, -1, 0, 1$ belong to the range(which are distinct)

In general $2^{n}$ distinct integers are possible with $n\text{-bit}\;2's$ Complement Number $\to X$

Sign Magnitude Representation

The range of $n\text{-bit}$ Sign Magnitude numbers is $- (2^{n-1}-1)$ to $+ (2^{n-1}-1)$

For example, if $n = 2$, then $-1, -0, +0, +1$ belong to the range in which $-0 = +0$ and both represent zero.

In general $2^{n}-1$ distinct integers are possible with $n\text{-bit}$ Sign magnitude representation $\to Y$

$X-Y =2^{n} - (2^{n}-1) =1.$

edited by
37 votes
37 votes

For N bits, Distinct values represented in 2's complement is -2n-1 to 2n-1 -1

Distinct values represented in Signed Magnitude is -(2n-1 -1) to 2n-1 -1

Difference is 1.

4 votes
4 votes

For N bits, Distinct values represented in 2's complement is -2n-1 to 2n-1 -1 

So the total distinct value is (2n) => Represented by  X 

Distinct values represented in Signed Magnitude is -(2n-1 -1) to 2n-1 -1 

So the total distinct value is (2n-1) => Represented by  Y

X - Y = (2n) - (2n-1) = 1 ANS

1 votes
1 votes
2's complement has one representation for 0 while signed magnitude has 2 representations for 0.

So answer is 2-1 = 1.
Answer:

Related questions

68 votes
68 votes
7 answers
1
18 votes
18 votes
5 answers
2