mid1w10sol - ECEn 324 Winter 2010 Midterm #1 Solution 1. a....

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 ECEn 324 Winter 2010 Midterm #1 Solution 1. Which of the following was NOT suggested by the text as a reason for the success of C? a. C was closely tied with Unix. b. C is small and simple. c. C was designed by an ANSI standard committee. d. C was designed for a practical purpose. Solution: Options a, b, and d are all made clear in the blue box on pages 3-4. It is also stated that the design was controlled by a single person, rather than a committee, so statement c is false and should have been selected. 2. Suppose I’m debugging a program in GDB . If I examine a byte of memory and see that it contains the ASCII code for ‘q’, which of the following can I safely conclude? a. The byte is definitely used by the program to store character data. b. The byte is character data or part of an instruction. c. The byte is character data, part of an instruction, or part of an integer. d. None of the above. (There are other possibilities for the byte.) Solution: On page 3 of the text, the authors state: “The only thing that distinguishes different data objects is the context in which we view them. For example, in different contexts, the same sequence of bytes might represent an integer, a floating point number, character string, or machine instruction.” You’d have to see how that particular memory location is used by the program to know what is actually stored there. The correct answer is d. 3. On a 32-bit little-endian machine, if a long stored at address A has value 0x12345678 , then the value of the byte at address A is a. 0x12 b. 0x34 c. 0x56 d. 0x78 Solution: The correct answer is d. See Section 2.1.4. 4. The decimal value of 0xffffffb8 interpreted as a two's complement number is a. a large negative number t, such that t < -2 30 b. a large positive number t, such that t > +2 30 c. -40 d. -72 e. none of the above Solution: The easiest thing to do here is to determine the magnitude of this negative two’s complement number by taking its two’s complement: flip all the bits and add 1. The result is 0x00000048, which is 64+8, or 72. Therefore, the original value was -72. 5. The value of 0xffffffb8 interpreted as a single-precision floating-point number is a. - b. a large negative number t, such that t < -10 20 c. a small negative number close to 0
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 d. 0 e. a small positive number close to 0 f. a large positive number t, such that t > +10 20 g. + h. NaN i. none of the above Solution: The first key here is to remember that the most significant bit is the sign bit, followed by some number of exponent bits, and the rest of the bits forming the fractional part of the value. You didn’t need to remember that a single precision float has 8 exponent bits – you can safely conclude that all exponent bits are 1s because of the value given. You should recall that both the highest and lowest possible values in the exponent field (all 1s and all 0s) represent special floating-point values – outside the range represented by “normalized” numbers. The design of
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

mid1w10sol - ECEn 324 Winter 2010 Midterm #1 Solution 1. a....

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online