CS 207
Midterm 2
Ondich
Due 8:30AM, Wednesday, November 6, 1996
HAND IN ON PAPER


You may use your textbook, your notes, a computer, your brain, and, if it is available to you, divine guidance on this exam. You may not other books, Internet resources, or other people.

I have tried to write an exam you can finish in eight or fewer hours. If it looks like you're going to take significantly longer than this, please let me know.

Explain your answers clearly. Have fun.

  1. (15 points) Your old friend Figure 4.15 on page 192 of Patterson and Hennessy includes a box labeled "Overflow detection." Draw a digital logic implementation of this box.
  2. (15 points) Do problem 5.7 on page 358 of H and P.
  3. (8 points) Playing with floating point numbers. The IEEE 754 standard for floating point numbers includes several special codes to represent the results of, shall we say, disapproved arithmetic. These codes are listed in the table on page 244 of P and H. Your task in this problem is to write a C program to demonstrate how ordinary arithmetic operations can cause a float-type variable to become +Infinity, -Infinity, Not a Number, and denormalized.

    Here's an example of a C program that shows how ordinary arithmetic operations can cause a float-type variable to become 6.25:

    
    #include	<stdio.h>
    
    void main( void )
    {
    	float		x, y, z;
    	
    	x = 12.5;
    	y = 2;
    	z = x / y;
    	
    	printf( "%f\n", z );
    	printf( "0x%x\n", (*((long *)(&z))) );
    }
    
    The last printf shows a C trick for taking a look at a hexadecimal expression for the 32-bit pattern stored in the variable z. Feel free to use this trick to check your answers, but don't consider such pointer manipulations to constitute "ordinary arithmetic operations."
  4. (4 points) Please tell me a joke. In return, let me tell you my favorite among all the jokes I have collected on exams.
         Q: What did Buddha say to the hotdog vendor?
         A: Make me one with everything.
    
    If you wish, you may prepare an essay on the Western misconceptions about Buddhism betrayed by this joke.
  5. (20 points) When I read Patterson and Hennessy's problem sets, I feel like I'm reading Aesop--but P and H make me figure out the morals to their computer architectural fables. Do problems 5.8 and 5.9 on pages 358-359 of P and H. When you're done, discuss the moral of these problems.




Jeff Ondich, Department of Mathematics and Computer Science, Carleton College, Northfield, MN 55057
(507) 646-4364, jondich@carleton.edu