Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!adm!V125KJG8%UBVMS.BITNET@wiscvm.wisc.edu From: V125KJG8%UBVMS.BITNET@wiscvm.wisc.edu Newsgroups: comp.lang.c Subject: Re: Floating Point Errors Message-ID: <5056@brl-adm.ARPA> Date: Fri, 20-Mar-87 13:27:16 EST Article-I.D.: brl-adm.5056 Posted: Fri Mar 20 13:27:16 1987 Date-Received: Sun, 22-Mar-87 14:32:31 EST Sender: news@brl-adm.ARPA Lines: 49 In article <652@sdchema.sdchem.UUCP> tps@sdchem.UUCP (Tom Stockfisch) writes: >In article <365@bms-at.UUCP> stuart@bms-at.UUCP (Stuart D. Gathman) writes: >>In article <4804@brl-adm.ARPA>,Schauble@mit-multics.arpa (Paul Schauble) writes: >>>...[claim that with float x,y, the test (x*y==x*y) can fail on many machines >Every single usage of "==" for floating point can fail? >What about > > double dflmax(); > double x = dflmax(); > > if ( x == dflmax() ) >or > double x = 0; > > if ( x == 0 ) > ... > > ? I can't accept the fact that (x * y == x * y) will fail, because the floating point will work the same way. Perhaps we mean something like this: if (7.0 * 5.0 == 35.0) /* which can fail */ Or, possibly this will fail: float x = 5.0, y = 7.0, z; z = x * y * y; z /= y; if (x * y == z) .. depending on how the CPU handles the floating point. Have fun and see yuh... --Curtis R. Anderson State University of New York at Buffalo (V125KJG8@UBVMS.bitnet) [opinions are my own, and do not necessairily represent views of SUNYAB. If they happen to do so, then that is strictly coincidence.]