Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!ima!mirror!xanth!kent From: kent@xanth.UUCP Newsgroups: comp.lang.c Subject: C, roundoff anomolies, and floating comparisions Message-ID: <821@xanth.UUCP> Date: Sat, 11-Apr-87 02:35:46 EST Article-I.D.: xanth.821 Posted: Sat Apr 11 02:35:46 1987 Date-Received: Sun, 12-Apr-87 01:05:42 EST References: <15958@sun.uucp> <5716@brl-smoke.ARPA> <14680@cca.CCA.COM> <790@xanth.UUCP> <995@wanginst.EDU> Reply-To: kent@xanth.UUCP (Kent Paul Dolan) Distribution: world Organization: Old Dominion University, Norfolk Va. Lines: 72 Keywords: C, IEEE Floating Point, register arithmetic, relational operands. Summary: We need a way to beat the guard bits problem. In article <995@wanginst.EDU> mckeeman@wanginst.EDU (William McKeeman) writes: >I am a bit frustrated by people talking past each other on this topic. The >order of evaluation rules in C are a blanket over several subproblems. >Conclusion: when making a pitch for a better C definition rule, identify >which of the problems: > unrestricted optimization > overflow anomalies > roundoff anomalies > side effect anomalies >it is designed to solve. If you don't intend for your rule to have >language-wide implications, state the limited area of application. >-- >W. M. McKeeman mckeeman@WangInst >Wang Institute decvax!wanginst!mckeeman >Tyngsboro MA 01879 I agree that this is an excellent idea, and, being nothing if not opinionated, and having freely confessed my disenchantment with C in its present state in this forum previously, I will start this discussion off with four new subjects corresponding to (Mr., Mrs., Miss, Ms., Dr., (?)) McKeeman's plan, and then sit back and read the responses. I don't have much new to offer for the third topic, so let me just summarize what I understand from previous postings and some (very out of date) computer hardware experience, plus wide reading over the years. Frequently, in order to extend the precision of floating point arithmetic, hardware round-off, and/or guard bits are provided by the hardware designer. The new IEEE floating point math standard is an excellent example of this. Typically (?) the rounding takes place, or the guard bits are dropped (or both), when the operand is returned from registers to main memory. This can cause a problem with relational operations between floating point variables. A particular example is that a computational quantity which is still in a register may fail a comparision for equality with the same datum which has been stored in memory and returned to a register. Previous postings have shown that the problem is not restricted to "==", but that "<=", "<", ">=", and ">" may all suffer from variations on the same theme, sometimes because the sum of the parts doesn't equal the whole when round-off error is taken into account, and sometimes because of the problem of applying rounding or dropping guard bits only when storing to memory. One solution to the latter problem is to have the compiler, any time it detects a relational comparision between two floating point quantities, force any values still in registers to memory and back, so that oranges are being compared to oranges. This might be put under the control of a compile time switch, for times when the performance penalty cannot be afforded, or the comparision is know to be either exact or more than "fuzz" different. A solution proposed to the former problem is to provide a level of "fuzz" in the comparision to account for "almost equal", and possibly to provide an optimized inline way to do the fuzzy relational operations. This seems not yet to be well specified. Comments? Kent. -- The Contradictor Member HUP (Happily Unemployed Programmers) // Also // A Back at ODU to learn how to program better (after 25 years!) \\ // Happy \// Amigan! UUCP : kent@xanth.UUCP or ...{sun,cbosgd,harvard}!xanth!kent CSNET : kent@odu.csnet ARPA : kent@xanth.cs.odu.edu Voice : (804) 587-7760 USnail: P.O. Box 1559, Norfolk, Va 23501-1559 Copyright 1987 Kent Paul Dolan. How about if we keep the human All Rights Reserved. Author grants race around long enough to see retransmission rights recursively only. a bit more of the universe?