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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c7637cfdf68e766 X-Google-Attributes: gid103376,public X-Google-Thread: 109d8a,c7637cfdf68e766 X-Google-Attributes: gid109d8a,public X-Google-Thread: f8362,c7637cfdf68e766 X-Google-Attributes: gidf8362,public X-Google-Thread: f43e6,c7637cfdf68e766 X-Google-Attributes: gidf43e6,public X-Google-Thread: 107079,c7637cfdf68e766 X-Google-Attributes: gid107079,public From: schlafly@bbs.cruzio.com Subject: Re: floating point comparison Date: 1997/08/08 Message-ID: <5sg43v$scm@redtail.cruzio.com>#1/1 X-Deja-AN: 262951048 Distribution: inet References: <33E61497.33E2@pseserv3.fw.hac.com> <5sar4r$t7m$1@cnn.nas.nasa.gov> Organization: Cruzio Community Networking Service Reply-To: schlafly@bbs.cruzio.com Newsgroups: comp.lang.ada,sci.math.num-analysis,comp.software-eng,comp.theory,sci.math Date: 1997-08-08T00:00:00+00:00 List-Id: In article , Gerhard Heinzel writes: > On 7 Aug 1997 schlafly@bbs.cruzio.com wrote: > Second, if you want to compare two numbers that come from some algorithm > (i.e. is an eigenvalue zero? is a pivot zero? is a correlation coefficient > unity?) In these cases one must NEVER test for exact equality, but always > take into account rounding errors and devise some test such as > > fabs(x-y) > or fabs((x-y)/y) > or something similar, depending on the situation. I don't agree. A program might have to only test for 0 pivots because it already has an error estimation piece that measures the effect of small pivots. Or it might have a lot of correlation coefficients which are exactly 1, and only want to compute some auxillary numbers when the coefficient is not 1. You seem to be presuming that if someone does not do error analysis in the style that you usually do it, then no error analysis is being done. On the contrary, if someone does a careful error analysis elsewhere in the program, then a floating point equality test can be quite harmless. Roger