Xref: utzoo comp.lang.misc:3288 comp.lang.c:20585 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ico!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.misc,comp.lang.c Subject: Re: IEEE floating point format Message-ID: <14268@haddock.ima.isc.com> Date: 11 Aug 89 18:07:43 GMT References: <2170002@hpldsla.HP.COM> <9697@alice.UUCP> <3554@buengc.BU.EDU> <9725@alice.UUCP> <3591@buengc.BU.EDU> <152@servio.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Followup-To: comp.lang.misc Organization: Interactive Systems, Boston Lines: 14 In article <152@servio.UUCP> penneyj@servio.UUCP (D. Jason Penney) writes: >note that with truncating underflow, it is possible to have two floating >point values X and Y such that X != Y and yet (X - Y) == 0.0, >thus vitiating such precautions as, > if (X == Y) error("zero divide"); else something = 1.0 / (X - Y); I used to have similar problems with the SIMULA compiler on TOPS-10, which apparently used fuzzy compare even against zero: (example in C notation) if (X < 0.0) error("neg sqrt"); else something = sqrt(X); would die because -1.0E-20 was considered "equal" to zero rather than negative, yet the sqrt() routine wasn't fooled. What a pain to work around! Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint (What's this doing in comp.lang.c? Followups to comp.lang.misc.)