The Perils of Floating Point
by Bruce M. Bush
Copyright (c) 1996 Lahey Computer Systems, Inc. Permission to copy is granted with acknowledgement of the source.
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: 1. More floating-point calculations are performed in FORTRAN than any other computer language. 2. I work for a company, Lahey Computer Systems, that develops and sells FORTRAN language systems.













