Floating point multiplication and division are performed in a manner similar to floating point addition and subtraction, except that the sign, exponent, and fraction of the result can be computed separately. If the operands have the same sign, then the sign of the result is positive. Unlike signs produce a negative result. The exponent of the result before normalization is obtained by adding the exponents of the source operands for multiplication, or by subtracting the divisor exponent from the dividend exponent for division. The fractions are multiplied or divided according to the operation, followed by normalization.
Consider using three-bit fractions in performing the base 2 computation: (+.101 × 22) × (−.110 × 2-3). The source operand signs differ, which means that the result will have a negative sign. We add exponents for multiplication, and so the exponent of the result is 2 + −3 = −1. We multiply the fractions, which produces the product .01111. Normalizing the product and retaining only three bits in the fraction produces −.111 × 2 -2.
Now consider using three-bit fractions in performing the base 2 computation: (+.110 × 25) / (+.100 × 24). The source operand signs are the same, which means that the result will have a positive sign. We subtract exponents for division, and so the exponent of the result is 5 – 4 = 1. We divide fractions, which can be done in a number of ways. If we treat the fractions as unsigned integers, then we will have 110/100 = 1 with a remainder of 10. What we really want is a contiguous set of bits representing the fraction instead of a separate result and remainder,
and so we can scale the dividend to the left by two positions, producing the result: 11000/100 = 110. We then scale the result to the right by two positions to restore the original scale factor, producing 1.1. Putting it all together, the result of dividing (+.110 × 25) by (+.100 × 24) produces (+1.10 × 21). After normalization, the final result is (+.110 × 22).
No comments:
Post a Comment