From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tim Hollebeek To: law@cygnus.com Cc: jbuck@Synopsys.COM, moshier@mediaone.net, tprince@cat.e-mail.com, bosch@gnat.com, burley@gnu.org, egcs@cygnus.com, hjstein@bfr.co.il Subject: Re: /internet Date: Wed, 16 Dec 1998 07:58:00 -0000 Message-id: <199812161558.KAA15763@wagner.Princeton.EDU> References: <25711.913779320@hurl.cygnus.com> X-SW-Source: 1998-12/msg00578.html 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 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."