When I wrote "The Perils of Floating Point", I had no idea of how great its reach would be. There are hundreds of links to it and thousands of references to the title. References include universities, programming documentation, published books and many blogs. I wish I could know how many people have been helped by this paper.
The Perils of Floating Point by Bruce M. Bush © 1996 Lahey Computer Systems, Inc.
Permission to copy is granted with acknowledgement of the source.
The Perils of Floating Point by Bruce M. Bush
Many great engineering and scientific advances of recent decades would not have been possible without the floating-point capabilities of digital computers. Still, some results of floating-point calculations look pretty strange, even to people with years of mathematical experience. I will attempt to explain the causes of some of these strange results and give some suggestions where appropriate.
Floating-point representations and arithmetic are inexact, but I don't believe that is particularly troublesome to most programmers. Many input values are measurements, which are inherently inexact, so the question about the output values isn't whether there is error, but how much error should be expected. However, when you can compute a more accurate result in your head than your computer can with its floating-point, you start to get suspicious.
I have programmed my examples in FORTRAN for a couple of reasons: