COMP SCI 241 Discrete Mathematics I

advertisement
COMP SCI 241 Discrete Mathematics I
HW # 4
Solutions.
Spring 2009
F. Baulieu
1) What is the range of values that can be represented using 32-bit twos complement form?
-232-1+1 to 232-1-1. I.e. -231+1 to 231-1. I.e. -2147483647 to +2147483647
2) Find the 8-bit twos complement of the binary string 1001110
Pad: 01001110
Flip: 10110001
Increment: 101100102c
3) Find the value of the 16-bit twos complement form number 1011111000110111
The 16th bit is a 1, so the number is negative. We take the twos complement to find its
magnitude:
Pad: 1011111000110111
Flip: 0100000111001000
Increment: 0100000111001001
In hex, this is 41C916=9+12(16)+1(256)+4(4096)=1684110
So our original value was 16841
4) Find the 8-bit twos complement representation of the value 103
Converting to binary thru hex: 103=6716=0110 01112. Since the value is to be positive, we leave
the representation in 8-bit binary.
Answer: 0110 01112c
Download