Related articles |
---|
inlining + optimization = nuisance bugs qjackson@wave.home.com (Quinn Tyler Jackson) (1998-06-18) |
Re: inlining + optimization = nuisance bugs bill@amber.ssd.csd.harris.com (1998-06-19) |
Re: inlining + optimization = nuisance bugs acoetmeur@icdc.caissedesdepots.fr (Alain Coetmeur) (1998-06-24) |
Re: inlining + optimization = nuisance bugs qjackson@wave.home.com (Quinn Tyler Jackson) (1998-08-10) |
Re: inlining + optimization = nuisance bugs cfc@world.std.com (Chris F Clark) (1998-08-10) |
Re: inlining + optimization = nuisance bugs darcy@usul.CS.Berkeley.EDU (1998-08-13) |
Re: inlining + optimization = nuisance bugs darcy@usul.CS.Berkeley.EDU (1998-08-13) |
Re: inlining + optimization = nuisance bugs joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-08-17) |
Re: inlining + optimization = nuisance bugs lindahl@cs.virginia.edu (1998-08-19) |
Re: inlining + optimization = nuisance bugs jfc@mit.edu (1998-08-19) |
Re: inlining + optimization = nuisance bugs joachim.durchholz@munich.netsurf.de (Joachim Durchholz) (1998-08-19) |
Re: inlining + optimization = nuisance bugs roy@prism.gatech.edu (1998-08-20) |
Re: inlining + optimization = nuisance bugs awf@robots.ox.ac.uk (Andrew Fitzgibbon) (1998-08-20) |
[21 later articles] |
From: | darcy@usul.CS.Berkeley.EDU (Joseph D. Darcy) |
Newsgroups: | comp.compilers |
Date: | 13 Aug 1998 22:05:19 -0400 |
Organization: | University of California, Berkeley |
References: | 98-08-056 98-08-075 |
Keywords: | optimize, arithmetic |
Chris F Clark <cfc@world.std.com> writes:
>way, I also listen to the other rule of thumb, which is to never
>compare two floating point numbers for equality, only for being "close
>enough".)
While that is often a prudent rule to follow, like many rules of
thumb, sometimes it is okay to break. For example, floating point
addition and multiplication on small integers is exact so it is okay
to compare for such numbers for equality. Also, comparing for
equality can also be used to remove certain singularities, like in
computing sinc x = sin x / x.
if(x == 0.0)
return 1.0; // from calculus, lim sinc x = 1.0
// x->0
else
return sin(x)/x;
If 0.0 was not tested for, a NaN would be returned (0.0/0.0 is NaN in
IEEE arithmetic).
-Joe Darcy
darcy@cs.berkeley.edu
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.