Date: Tue, 05 Nov 1996 00:32:14 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Thu, 10 Oct 1996 20:02:36 GMT Content-length: 5639 JT-HW3.ans.html

CS354, Fall 1996

Homework 3, due Wednesday October 9 at the start of class.

Name (printed):

Name (signed):

Grader:

Mohammad

 

Sridevi

 

Sunlung

 

Total score:

(1) (4 points) Find the largest IEEE 32 bit floating point number that does not have an integer value. Express the answer in binary and in decimal.

ANSWER

all FPS numbers larger than:
100000000000000000000000.02 = 223 have integer values
since
the significant only holds 23 bits
 
the next smaller FPS number is:
 11111111111111111111111.12 = 223 - 0.5 =
8388607.510

 

(2) (2 points each, 6 points total) Write the hexadecimal values for x, y and z just after the following code executes:

ANSWER
move x, 0x0f0fc123
and  x, x, 0xff00f000      # x = 0x0f00c000
not  x, x                  # x = 0xf0ff3fff <- ans
move y, 0x8f0aabc9
sll  y, y, 5               # y = 0xe1557920 <- ans
nor  z, x, y               # z = 0x0e008000 <- ans

 

(3) (3 points each, 6 points total) Do the following 2's complement multiplication. Indicate if either computation overflows for 12 bit words, for 6 bit words. Show your work. Check your results by redoing the computation in decimal.

          001010                                    001010            
        x 111100                                  x 000011

        --------                                  --------
 
ANSWER
 
    111111111100 <-  sign extend the -410            001010 <-  1010
          x 1010 <-  1010                          x 000011 <-   310
    ------------                                  --------
   1111111111000                                    001010
 111111111100                                      001010
----------------                                  --------
1001111111011000 <- 011000 is 2410                 0011110 <-  011110 is 3010
                    in 6 bit, 2's comp                         in 6 bit, 2's comp
 
111111011000 is -40 in 12 bit 2's comp,            no overflow in 12 or 6 bits
no overflow for 12 bit words but overflow
for 6 bit words
     

(4) (4 points) Show that the following two code segments give the same value for c, for any values of a and b. Hint: consider truth tables (see page 116 of the text).

and c, a, b          not c, a
not c                not d, b
                     or  c, c, d

ANSWER

the first sequence is not(a and b)
while the second is (not(a) or not(b))
column 4 and 7 of the following truth table are the same
so not(a and b) is the same as not(a) or not(b)
 
a     b    (a and b)  not(a and b)   not(a)   not(b)   (not(a) or not(b))
0     0        0           1           1        1              1
0     1        0           1           1        0              1
1     0        0           1           0        1              1
1     1        1           0           0        0              0