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: f43e6,c7637cfdf68e766 X-Google-Attributes: gidf43e6,public X-Google-Thread: 109d8a,c7637cfdf68e766 X-Google-Attributes: gid109d8a,public X-Google-Thread: f8362,c7637cfdf68e766 X-Google-Attributes: gidf8362,public From: David Ullrich Subject: Re: floating point comparison Date: 1997/08/09 Message-ID: <33ECA115.13DE@math.okstate.edu>#1/1 X-Deja-AN: 263148250 Distribution: inet References: <33E61497.33E2@pseserv3.fw.hac.com> <5sar4r$t7m$1@cnn.nas.nasa.gov> <5sbb90$qsc@redtail.cruzio.com> Organization: OSU Newsgroups: comp.lang.ada,sci.math.num-analysis,comp.software-eng,comp.theory,sci.math Date: 1997-08-09T00:00:00+00:00 List-Id: Robert Dewar wrote: [...] Well, curiously it turns out that the question of the accuracy of floating-point operations matters to me more than it did when the thread started. You and a few others have made points about how in some situations it can be perfectly appropriate to test for equality. If we're talking about comparing two numbers that we just came up with somehow fine, I can believe that. But what if, say, an integer of some sort is going to be read from a file, and then converted to another integer by some algorithm? Maybe we read a byte b from the file, and then we want to use n:= Trunc(Log(b + 1) * 64000) later, "or something like that". It doesn't matter whether n gets exactly the "right" value or not, but it's crucial that the same b _always_ leads to the same n, even on different systems. Surely I can't depend on floating-point operations being standard enough for this, can I? (My plan at present is to use the floating-point to give a first approximation, and then verify/tweak n by purely integer operations until it passes some test defined by integer operations. Doesn't have to be fast, this only happens once or twice.) Seems like there must be _some_ error allowed in the standard standards, and any error at all means I can't trust the floating-point here. Please tell me I'm wrong; it would save me some work. -- David Ullrich ?his ?s ?avid ?llrich's ?ig ?ile (Someone undeleted it for me...)