CS130 Homework 2 Solution

due January 23

Floating Point Numbers

For full credit, show your work!

1. Convert 7.34 to an 8-bit floating point number number.
mantissa   exp
7.34         0
3.67         1
1.835      2

Number is positive => S = 0
exp = binary(2+4) = 110
mantissa = binary((1.835 -1)/16) = binary (13.36) = =binary(13) =1101

ANSWER: = 01101101

2. Convert -0.68 to an 8-bit floating point number

mantissa   exp
0.68         0
1.36         -1
Number is negative => S = 1
exp = binary(-1 + 4) = 011
mantissa = binary(1.36 -1)/16) = binary (5.76) = binary (6) = 0110

ANSWER: 10110110

3. Convert  00010110 from  floating point binary representation to decimal:

0 001 0110
S = 0 => positive
exp = 1-4 = -3
mantissa = 1 + 6/16
ANSWER = 22/16 * 2-3  = 22/128 =11/64 = 0.171875

4. Convert   10000101 from  floating point binary representation to decimal:

1 000 0101
S = 1 => negative
exp = 0 - 4 = -4
mantissa = 1 + 5/16

ANSWER: = - 21/16 * 2-4 = -21/256 = 0.08203125

5. Give two ways in which the quality of digital representation of music can be improved

a. Increase the precision of the measurements (more bits to hold each value)
b. Increase the number of samples