This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: /internet
- To: law at cygnus dot com
- Subject: Re: /internet
- From: Tim Hollebeek <tim at wagner dot princeton dot edu>
- Date: Wed, 16 Dec 1998 10:58:20 -0500 (EST)
- Cc: jbuck at Synopsys dot COM, moshier at mediaone dot net, tprince at cat dot e-mail dot com, bosch at gnat dot com, burley at gnu dot org, egcs at cygnus dot com, hjstein at bfr dot co dot il
Jeffrey A Law writes ...
>
> You understand my suggestions correctly.
>
> But I'm neither a language lawyer, nor an ieee/fp expert, so you have to take
> my suggestions with some care. I certainly wouldn't actually make such changes
> without being 100% they're safe according to the language specs and don't
> violate the principle of least suprise too often. For that I would have to
> lean on folks in on this list to guide me through the pitfalls of each
> language and ieee/fp.
I believe the example you were talking about yesterday violates IEEE,
since the reordering you suggested can change the value of the result
(by causing an intermediate (c*d) to overflow, when left to right
evaluation would not cause an overflow):
#include <math.h>
int main() {
int z = 400;
double a = scalb(1, -z);
double b = scalb(1, -z);
double c = scalb(1, z);
double d = scalb(1, 2*z);
double t1, t2, t3;
t1 = a*b;
t2 = t1*c;
t3 = t2*d;
printf("--> %g\n", t3);
t1 = a * b;
t2 = c * d;
t3 = t1 * t2;
printf("--> %g\n", t3);
}
---output---
--> 2.58225e+120
--> inf
---------------------------------------------------------------------------
Tim Hollebeek | "Everything above is a true
email: tim@wfn-shop.princeton.edu | statement, for sufficiently
URL: http://wfn-shop.princeton.edu/~tim | false values of true."