From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d8a,c7637cfdf68e766 X-Google-Attributes: gid109d8a,public X-Google-Thread: 107079,c7637cfdf68e766 X-Google-Attributes: gid107079,public X-Google-Thread: f43e6,c7637cfdf68e766 X-Google-Attributes: gidf43e6,public X-Google-Thread: f8362,c7637cfdf68e766 X-Google-Attributes: gidf8362,public X-Google-Thread: 103376,c7637cfdf68e766 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: floating point comparison Date: 1997/07/31 Message-ID: #1/1 X-Deja-AN: 261009075 References: <33E03DBC.4E82ED1C@Physik.Uni-Magdeburg.DE> Organization: New York University Newsgroups: comp.lang.ada,sci.math.num-analysis,comp.software-eng,comp.theory,sci.math Date: 1997-07-31T00:00:00+00:00 List-Id: Gerald says <> Nothing "fails" due to rounding errors on modern IEEE machines. What is wrong here is not some kind of failure in the arithemtic, but the programmers misuse of it. Of course if you expect to be able to take an algorithm which is "exact" using real arithmetic, it is often completely bogus to simply encode it using floating point arithmetic, that's exactly what I mean by "approximate hocus pocus". If you try to store 1001 numbers in a 1000 array, your program malfunctions, but you immediately understand that the program is wrong, you do not blame the array for "failing". Misuse of IEEE floating-arithmetic is the same as any other bug a careless programmer introduces into their program. As to whether equality is what you want, it is a well defined operation, you use it when and only when you want this operation. It is certainly not the case that if the real arithmetic algorithm you are using as an implementation model has an equality that you should blindly use the equality IEEE operation. But then it is equally foolish to think that you can blinndly translate an addition to to a floating-point add. Any kind of blind unthinking behavior is likely to get you into big trouble. As (one) example of a case where equality is approrpiate, consider the problem of computing a square root by Newton Raphson, using round-towards-zero. In this situation, the estimate will converge accurately to IEEE equality. Floating-point code is had stuff, most people who do it shouldn't!