Homework 7

22C:18, Fall 1996

Due Tuesday Oct. 22, 1996 in discussion

Douglas W. Jones
  1. Convert the following unsigned binary fixed point numbers to decimal:
    	a) 101.101	d) 100.010
    	b) 110.011	e) 111.001
    	c) 100.001	f) 101.111
    

  2. Convert the following decimal numbers to their nearest fixed point binary equivalents. Assume 2's complement is used for negative numbers, and that the numbers are 16 bits each, with an 8 bit fractional part.
    	a)  10.00	d) -10.0125
    	b) -20.625	e)  63.984375
    	c) 100.001	f) -15.9375
    
  3. Consider the problem of printing fixed-point binary numbers. Write a procedure called dspfix that takes an unsigned fixed point binary number in R3, with a 12 bit fraction and a 20 bit integer part, and prints it on the screen in decimal, using DSPCH and DSPDEC.

    Hint: First split off the integer part and print it using DSPDEC, then print the point, then print successive digits of the fraction by repeatedly multiplying by 10, knocking off the integer part and printing it.

  4. Convert the decimal number 1000.1 to each of the following 32 bit binary floating point formats; all have the sign of the mantissa as the most significant bit, all have the exponent between sign and mantissa, and all are normalized:
    1. An 8-bit 2's complement binary exponent with a 2's complment mantissa and no hidden bit.

    2. An 8-bit biased binary exponent with signed-magnitude mantissa and no hidden bit.

    3. An 8-bit signed magnitude exponent with a signed-magnitude mantissa and a hidden bit.

    4. A 12-bit biased exponent with a signed-magnitude mantissa and no hidden bit.

  5. Write SMAL Hawk procedures to pack and unpack floating point numbers. In the packed form, each number is a single 32 bit value in R3, with signed magnitude mantissa, 8-bit biased exponent and no hidden bit. In the unpacked form, each number is a two's complement fixed point fractional mantissa in R3 and a two's complement exponent in R4. These representations were discussed at length in the notes.