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: 107079,c7637cfdf68e766 X-Google-Attributes: gid107079,public X-Google-Thread: 103376,c7637cfdf68e766 X-Google-Attributes: gid103376,public X-Google-Thread: f8362,c7637cfdf68e766 X-Google-Attributes: gidf8362,public X-Google-Thread: 109d8a,c7637cfdf68e766 X-Google-Attributes: gid109d8a,public X-Google-Thread: f43e6,c7637cfdf68e766 X-Google-Attributes: gidf43e6,public From: Gerald Kasner Subject: Re: floating point comparison Date: 1997/07/31 Message-ID: <33E03DBC.4E82ED1C@Physik.Uni-Magdeburg.DE>#1/1 X-Deja-AN: 260863559 References: Organization: Univ. of Magdeburg, Dept of CS, Germany 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: Robert Dewar wrote: > > iMatthew Heaney quotes the AQ&S with respect to its advice on comparing > floating-point numbers. > > Please don't quote this section, it contains a fair bit of embarassing > nonsense. > > As for when it makes sense to compare floating-point values for equality, > that is a matter for the programmer to understand. Floating-point arithmetic > on modern IEEE machines is not some kind of approximate hocus-pocus, it > is a well defined arithmetic systenm, with well defined, well behaved > results, in which equality has a perfectly reasonable meaning. Hm, have you ever tried to understand the first chapters on rounding erros in some textbook on linear algebra ? (or try Wilkinson:Rounding Errors (very old, but good) ) Or try to understand the routines in the well known book of Wilkinson and Reinsch (linear algebra II), which many routines of Linpack/Eispack or Lapack are based on. Things you call approximate hocus-pocus make life hard if you try to implement some algortithms wich are exact (in exact arithmetic), but fail due to rounding erros EVEN ON MODERN IEE MACHINES. Comparing floating point numbers for equality should be avoided, the programmer need some deeper insight of the problem. -Gerald -- ############################################## # Dr. Gerald Kasner # # Gerald.Kasner@Physik.Uni-Magdeburg.de # # Tel.: Germany +391 / 67 / 12469 # # Fax.: Germany +391 / 67 / 11131 # ##############################################