|
In some ways, understanding the details of how floating-point works is like understanding the details of how your car's power train works. Just as most folks do just fine driving their car without knowing how the drive train functions, most programmers do just fine writing programs using floating-point without knowing how their computer manipulates the data. The details just don't seem that important. Until there is a problem. Getting StartedIf you are just a bit curious about floating point or need to dig more deeply into it, I've written a small tutorial here and a short program to let you explore the format and get more familiar with it. As always, all source code is provided. Hopefully, you will find the pages and the programs useful.
The above program is currently at version 5, which includes:
Some of the included code I've included in FLOATEXP.ZIP requires a Quick BASIC compiler, such as QB 4.5. But this ZIP file also includes a program used to display the floating point format of various values, FLOATQB.BAS, which will run just fine with QBASIC and without any of the compiler tools. You can pick up your own free QBASIC program from Microsoft, if you are lacking it, by going to that section of my PC Tools page and picking up the download from there. In addition, Microsoft has also prepared a web page on floating point and Quick BASIC.
I also recommend getting Intel's documentation on the x86 processor, which includes a long section on the details of floating point numbers. It will take some getting used to, if this is your first time. But there is a lot of information kept there.
Finally, for those seriously interested in learning more about floating point, beyond what is already included in the Intel manuals for example, this widely distributed paper is definitely worth reading or skimming.
Feel free to email me. Last updated: Wednesday, July 06, 2005 12:50 |