Assignment 1

advertisement
95.102
Assignment 1
Winter 2001
This assignment is for Sections C and E. If you are in Section
D, please do the one that your professor asks!
Assignment 1
95.102, Winter 2001
Due January 22
Total = 50 marks
A. Unsigned integer representations.
1. (4 marks) Consider the following integers:
(i) 5096;
(ii) 11357.
(a) Suppose an integer is stored in two bytes (i.e., 16 bits). Find the bit patterns used to
represent these integers.
(b) Write the bit patters that you found in question 2 in hexadecimal form.
2. (6 marks) Consider the following hexadecimal integers:
(i) 1234;
(ii) ABCD;
(iii) FFFF.
(a) What are these integers in binary form?
(b) What are these integers in the decimal form?
B. Signed integer representations.
3. (6 marks) Suppose an integer is stored in two bytes. Find the bit patterns used to
store the following integers: (Write your bit patterns in the hexadecimal notation.)
(i) 0;
(ii) 5096;
(iii) 11357.
(a) In excess-32767 notation. (32767 = 215  1)
(b) In two's complement notation.
4. (4 marks) What are the integers represented by the following bit patterns?
(i) 6A2B;
(ii) B2A6.
(a) The bit patterns are in excess-32767 notation.
(b) The bit patterns are in two's complement notation.
1
95.102
Assignment 1
Winter 2001
C. Integer arithmetic.
5. (8 marks) Add the following bit patterns (8 bits in hexadecimal form). Identify each
case in which the answer is incorrect due to overflow.
(i) 3A + 67;
(iii) B1 + EA;
(ii) 4B + A3;
(iv) 92 + DA.
(a) Assume the bit patterns represent unsigned integers.
(b) Assume the bit patterns represent signed integers in two's complement notation.
6. (8 marks) Subtract the following bit patterns (8 bits in hexadecimal form). Identify
each case in which the answer is incorrect due to overflow.
(i) 21  4C;
(iii) CA  3B;
(ii) AB  5D;
(iv) 7A  A7.
(a) Assume the bit patterns represent unsigned integers.
(b) Assume the bit patterns represent signed integers in two's complement notation.
7. (2 marks) Suppose the following bit patterns represent integers in two' complement
notation by two bytes.
(i) 4ABC;
(ii) CBA4.
Find the bit patterns that represent the same integer in two's complement notation by four
bytes.
C. Floating-point number representation.
Suppose a floating-point number is stored in one byte. The first bit is the sign bit, the
next three bits represent the exponent in excess-3 notation, and the rest four bit stores the
decimal part of the mantissa.
8. (2 marks) Find the largest number that this notation can represent. What is the bit
pattern?
9. (2 marks) Find the smallest positive number that this notation can represent. What is
the bit pattern?
10. (2 marks) List all numbers in the interval [0.75, 0.625] that can be exactly
represented by this notation.
2
95.102
Assignment 1
Winter 2001
11. (2 marks) List all numbers in the interval [10, 12] that can be exactly represented by
this notation.
12. (2 mark) Use at most two sentences to express your observation, obtained from the
answers to Questions 10 and 11, about the distribution of the numbers that be exactly
expressed by this notation on the real axis.
13. (2 marks) Express the real number 3.6 in this notation. Find the round off error.
3
Download