The CPU is primarily designed to perform basic math operations on integers with a precision of up to approximately 9 significant digits. The range for 32-bit registers is approximately +/- 2.15*109. Although it is possible to write algorithms which can expand that precision and range, and/or perform computations with fractional values, it is generally slow and tedious.
The FPU is designed to perform math operations with a precision of up to approximately 19 significant digits. In addition to handling positive and negative values, those can be as small as approx. 3.36*10-4932 or as large as approx. 1.19*104932. In addition, specific instructions are available for math functions which are not directly provided by the CPU, such as extracting a square root or computing trigonometric, logarithmic and exponential values.
With HLLs, the use of the FPU is very transparent; the proper code is generated by the compiler depending on how the variables are declared. However, using the FPU is very different from using the CPU in assembly.
In early 2003, hutch invited me to prepare a tutorial on the use of the FPU to help beginners. My goal was then to prepare a guide which may complement other tutorials available in the literature. By seeing different approaches to explanations, students may thus gain a better understanding of the subject. The project was completed by mid-August. Since then, some minor corrections have been made based on some constructive feedback.
If this is your first experience with the FPU, be sure to read AND understand the content of the first two chapters. Without that background knowledge, you definitely increase the risk of falling into the numerous pitfalls of FPU programming, in addition to misunderstanding some of the requirements of the various instructions.
You can view and study the tutorial on-line, or download the entire tutorial (in .html format) as a zipped file.
If, for some reason, you would want to have some or all the chapters in .PDF format for printing purposed, a free converter is available at the following URL:
Prior to the preparation of the FPU tutorial, a library of floating point functions had been prepared. Its primary purpose was to help beginners in using the high precision computing power of the FPU before they could become familiar with the intricacies of using FPU instructions.
The library consists of the usual arithmetic, trigonometric, hyperbolic, logarithmic and exponential functions. The ASCII-to-float and float-to-ASCII conversion functions are also available in addition to a few other general purpose functions.
The zipped package comes complete with the source code of each function and an extensive Help file (API style) covering the detailed requirements and expectations for each function. The Help file also provides an example of the code to compute the monthly payments on a loan, computations being done strictly with calls to the library functions.