|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ä |
Solution:
2’s complement representation
|
|
|
|
ä |
To
negate a value take the 2’s complement
|
|
|
|
i)
complement every bit (flip) 0->1 and 1->0
|
|
|
|
ii)
add 1
|
|
|
|
Consider
the decimal value (+1), take its 2’s complement
|
|
|
0001
-> i) 1110
|
|
|
|
ii) 0001
|
|
|
|
Add
to get 1111 This value represents (-1) decimal
|
|
|
|
ä |
Add
the two together
|
|
|
|
1 0000
|
|
|
|
ä |
We
truncate to keep the 4 lowest bits => 0000
|
|
|
|
ä |
We
ignore the 5th bit (ie the carry over bit for now)
|
|
|
ä |
In
general, for 2’s complement M bit values we
|
|
|
|
have
the range -2M-1 to 2M-1 -1
|
|