Numerical pitfalls without extended precision FPUs
Monniaux's 开发者_开发技巧excellent article, "The Pitfalls of Verifying Floating Point Arithmetic", gives examples of unexpected numerical behavior. However, most of the examples depend on extended precision FPUs or extended precision operations (e.g. multiply-accumulate). Besides signed zero and comparisons involving NaN are there any good examples of surprising numerical behavior when extend precision hardware is disabled?
An example that is often surprising to programmers is when x + 1 == x
. In single precision floating point, this is true for x
as small as 2^25
because of the limited precision of the mantissa. This often comes up when incrementing time values in a simulation by a small timestep. A similar problem affected the Patriot missile.
精彩评论