Книга: Advanced PIC Microcontroller Projects in C
1.22.3 Multiplication and Division of Floating Point Numbers
Разделы на этой странице:
1.22.3 Multiplication and Division of Floating Point Numbers
Multiplication and division of floating point numbers are rather easy. Here are the steps:
• Add (or subtract) the exponents of the numbers.
• Multiply (or divide) the mantissa of the numbers.
• Correct the exponent.
• Normalize the number.
• The sign of the result is the EXOR of the signs of the two numbers.
Since the exponent is processed twice in the calculations, we have to subtract 127 from the exponent.
An example showing the multiplication of two floating point numbers follows.
Example 1.36
Show the decimal numbers 0.510 and 0.7510 in floating point and then calculate their multiplication.
Solution 1.36
Convert the numbers into floating point as:
0.510 = 1.0000 ? 2-1
here, s = 0, e – 127 = -1 or e = 126 and f = 0000
or,
0.510 = 0 01110110 (1)000 0000 0000 0000 0000 0000
Similarly,
0.7510 = 1.1000 ? 2-1
here, s = 0, e = 126 and f = 1000
or,
0.7510 = 0 01110110 (1)100 0000 0000 0000 0000 0000
Multiplying the mantissas results in “(1)100 0000 0000 0000 0000 0000.” The sum of the exponents is 126+126=252. Subtracting 127 from the mantissa, we obtain 252–127=125. The EXOR of the signs of the numbers is 0. Thus, the result can be shown in floating point as:
0 01111101 (1)100 0000 0000 0000 0000 0000
This number is equivalent to decimal 0.375 (0.5?0.75=0.375), which is the correct result.
- 1.22.4 Addition and Subtraction of Floating Point Numbers
- Разработка приложений баз данных InterBase на Borland Delphi
- Open Source Insight and Discussion
- Introduction to Microprocessors and Microcontrollers
- Chapter 6. Traversing of tables and chains
- Chapter 8. Saving and restoring large rule-sets
- Chapter 11. Iptables targets and jumps
- Chapter 5 Installing and Configuring VirtualCenter 2.0
- Chapter 16. Commercial products based on Linux, iptables and netfilter
- Appendix A. Detailed explanations of special commands
- Appendix B. Common problems and questions
- Appendix E. Other resources and links