This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: optimization/9654: extra-precision fp comparisons are less accurate


The following reply was made to PR optimization/9654; it has been noted by GNATS.

From: Richard Addison-Wood <richard@wetafx.co.nz>
To: rearnsha@gcc.gnu.org
Cc: gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org
Subject: Re: optimization/9654: extra-precision fp comparisons are less accurate
Date: Fri, 14 Feb 2003 16:48:38 +1300

 It's quite reasonable to assume that
 
   acos(1-0.5*DBL_EPSILON)
 
 will not be 0.  For a value of d that is
 nearly 1:
 
   acos(d) == sqrt(1-d*d)
 
 is a good approximation (certainly within
 representational limits ieee754 double
 precision).  The point to notice here is that
 if d is distinguishable from 1, d*d will be
 even more distinguishable from 1.  All told,
 it very reasonable to expect:
 
   acos(1-0.5*DBL_EPSILON) == sqrt(DBL_EPSILON)
 
 which is a value that is not particularly
 close to 0.  However, it is still close
 enough to 0 so that:
 
   sin(sqrt(DBL_EPSILON)) == sqrt(DBL_EPSILON)
 
 is a good approximation.
 
 Of course, this discourse into acos(), sin(),
 and sqrt() is beside the point.  With code
 like this:
 
   if (d < 1.0)
   {
     arglessthanone(d);
   }
 
 it should be the case that the arglessthanone()
 function should not see an argument value that
 is greater than or equal to 1.0.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]