This preview has intentionally blurred parts. Sign up to view the full document

View Full Document

Unformatted Document Excerpt

Andrew login ID: Full Name: CS 15-213, Fall 2006 Exam 1 Wednesday October 4, 2006 Instructions: Make sure that your exam is not missing any sheets, then write your full name and Andrew login ID on the front. Write your answers in the space provided below the problem. If you make a mess, clearly indicate your final answer. The exam has a maximum score of 56 points. The problems are of varying difficulty. The point value of each problem is indicated. Pile up the easy points quickly and then come back to the harder problems. This exam is OPEN BOOK. You may use any books or notes you like. Calculators are allowed, but no other electronic devices. Good luck! 1 (8): 2 (8): 3 (8): 4 (6): 5 (8): 6 (8): 7 (10): TOTAL (56): Page 1 of 10 Problem 1. (8 points): Assume we are running code on an IA32 machine, which has a 32-bit word size and uses twos complement arithmetic for signed integers. Consider the following definitions: int x = foo(); unsigned ux = x; Fill in the empty boxes in the table below. For each of the C expressions in the first column, either: State that it is true of all argument values, or Give an example where it is not true. Puzzle True / Counterexample x < 0 (x * 2) < 0 False (TMin) x > 0 (x+1) > 0 x > 0 (x + 2) <= 0 (x>>31) == -1 x < 0U x < 0 ((x x>>31) + 1) > 0 ((x>>31)+1) == (x>=0) x >= 0 ((!x - 1) & x) == x ((int)(ux >> 31) + 0) == -1-(x | (x + 1)) > 0 Page 2 of 10 Problem 2. (8 points): Consider the following 5-bit floating point representations based on the IEEE floating point format. This format does not have a sign bit it can only represent nonnegative numbers. There are k = 3 exponent bits. The exponent bias is 3. There are n = 2 fraction bits. Numeric values are encoded as a value of the form V = M 2 E , where E is exponent after biasing, and M is the significand value. The fraction bits encode the significand value M using either a denormalized (exponent field 0) or a normalized representation (exponent field nonzero).... View Full Document

End of Preview

Sign up now to access the rest of the document