Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.UUCP Newsgroups: comp.lang.c Subject: Re: C and Floating Point Message-ID: <5731@brl-smoke.ARPA> Date: Mon, 6-Apr-87 21:55:28 EST Article-I.D.: brl-smok.5731 Posted: Mon Apr 6 21:55:28 1987 Date-Received: Sat, 11-Apr-87 08:19:47 EST References: <15958@sun.uucp> <5716@brl-smoke.ARPA> <14680@cca.CCA.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 39 Keywords: C Fortran Floating Point In article <14680@cca.CCA.COM> g-rh@CCA.CCA.COM.UUCP (Richard Harter) writes: >... From a mathematicians >viewpoint 'x + y + z', where x, y, and z are floating point numbers >and '+' is floating point addition, is not well defined. ... People who use floating-point numbers practically always think of them as modeling the mathematical "real number" system. The point that we agree on is that this model is inexact. There seems to be disagreement on whether mathematicians think that, in an expression such as "x + y + z", the "+" symbolizes machine (approximate) addition or real number (exact) addition. I'm sure that the latter is what most would think of. If the domain has been agreed to be complex numbers, rings, or some other algebra than the usual real number field arithmetic, then of course the "+" signs are assumed to have corresponding meaning. Most times that I see discussions of machine floating-point arithmetic, some symbol such as a circled + sign is used instead of "+" to represent the machine operation. When people say that "mathematicians" use () to indicate the sequential order in which operations are carried out, they're simply wrong (for most conventional mathematics as I was taught it through graduate school). The () indicate a logical grouping; usually there is no time sequence implied whatsoever (there IS a logical hierarchy imposed by (), but due to various identities any of a number of computationally distinct expressions may be exactly equivalent mathematically). Actually, many mathematicians may have never given this matter any thought, because it didn't seem necessary. I don't argue that evaluation sequence is not what *Fortran programmers* mean by (), but that's not the same as what *mathematicians* mean, and I can't allow an attempt to appeal to existing mathematical practice to be used in this debate when it is mistaken. Next we'll be hearing that mathematicians use "=" (or even more laughably, ":=") to mean assignment. In any case, X3J11 has provided the means to not specify order of evaluation when it's unimportant, and to specify order of evaluation when it is. The only beef seems to be that we didn't limit C to act "just like Fortran". What I haven't heard are good arguments why C should be made less flexible in this regard. It runs counter to the general "spirit of C" to impose such unnecessary constraints without adding any power thereby.