Article View: comp.arch
Article #11971IEEE arithmetic (Goldberg paper)
From: jbs
Date: Fri, 07 Jun 1991 01:12
Date: Fri, 07 Jun 1991 01:12
47 lines
2504 bytes
2504 bytes
Richard Firth quotes the fortran standard:
Evaluation of Arithmetic Expressions
... Once the interpretation has been established in
accordance with these rules, the processor may
evaluate any mathematically equivalent expression,
provided that the integrity of parentheses is not
violated.
Two arithmetic expressions are mathematiccally
equivalent if, for all possible values of their
primaries, their mathematical values are equal.
However, mathematically equivalent arithmetic
expressions may produce different computational
results.
to conclude:
In otherwords: yes, Jim Dehnert is fully entitled to replace 0.0*X
with the mathematically equivalent expression 0.0;
Some comments:
1. The question is not what fortran requires but what IEEE imple-
mented in fortran requires. One of the problems with IEEE's infs and
NaNs is that they do not fit well with fortran.
2. Appeals to a standard which predates IEEE are not totally con-
vincing. What does the Fortran 90 standard say?
3. In any case my reading of the standard is opposed to yours.
Infinity is a possible value of x, 0*infinity does not have math-
ematical value 0, therefore 0*x is not mathematically equivalent to 0
in IEEE.
Do you replace 0*x with 0 when compiling without optimization?
I think that if a (legal) program behaves differently when compiled with
and without optimization that then the compiler is broken. Perhaps you
disagree.
How would you handle 0-x? Goldberg in his paper (p.33) spec-
ifically forbids replacing it with -x although the fortran standard
would appear to permit it since mathematically +0=-0.
Richard Firth also said:
... anyone
who writes rubbish like
IF (0.0*X .NE. 0.0)
would be well advised to take the trouble to learn the language
in which he is attempting to write code.
So how would you code this (detecting whether x inf or NaN)?
James B. Shearer
Technical Details
Message-ID:
<9106070109.AA02137@ucbvax.Berkeley.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!WATSON.IBM.COM!jbsShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!ucbvax!WATSON.IBM.COM!jbs From: jbs@WATSON.IBM.COM Newsgroups: comp.arch Subject: IEEE arithmetic (Goldberg paper) Message-ID: <9106070109.AA02137@ucbvax.Berkeley.EDU> Date: 7 Jun 91 01:12:54 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 47