Homework 5

advertisement
CSCI 170 Spring 2010, Homework 5
Due: 3/30/10 at class time
If you do not show your work, you will receive at most half
credit even if your answer is correct.
1. (12 pts.) If a computer uses 16 bits to represent integer values (show your work):
1. What is the largest unsigned value that can be represented? Show the value in
both its original binary form and in decimal.
2. What are the largest (in absolute value) positive and negative signed integers that
can be represented using sign-magnitude notation? Show the values in both the
original binary form and in decimal.
3. What are the largest (in absolute value) positive and negative signed integers that
can be represented using two's complement notation? Show the values in both in
the original binary form and in decimal.
2. (8 pts.) Assume that the following 4-bit numbers represent signed integers using
sign/magnitude notation. The sign is the leftmost bit and the remaining 4 bits represent
the magnitude. What is the base-ten (decimal) value of each? Show your work.
a. 1111
b. 0110
c. 1110
d. 1000
3. (8 pts.) Assume that the following 4-bit numbers represent signed integers using two's
complement notation. What is the base-ten (decimal) value of each? Show your work.
a.
b.
c.
d.
1111
0110
1110
1000
4. (10 pts.) We've seen base 2 (binary) notation for values; an example of a base that is less
than 10. Bases higher than 10 are also useful. In particular, computer scientists frequently
use Hexadecimal (base 16). In this base, the first ten digits are represented as 0-9, with
A,B,C,D,E,F representing 10-15. On each of these, show your work.
a. Convert the values 320 and 18 from Base 10 to Hexadecimal.
b. Convert the values 11 and AE from Hexadecimal to Base 10.
c. Convert DD from Hexadecimal to base 2 and convert 10100000 (an unsigned
binary number) to Hexadecimal.
5. (8 pts.) Assume that a=1, b=2, and c=3. What is the value of each of the following
Boolean expressions (! designates NOT):
a.
b.
c.
d.
(a > 1) OR (b > c)
!(((a+b) ≥ c) AND (b ≤ c))
! ((a+b) ≥ c) OR ! (b ≤ c)
!(a > 1) AND (b > c)
Download