From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5476 invoked by alias); 12 Feb 2003 17:56:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 5462 invoked by uid 71); 12 Feb 2003 17:56:00 -0000 Date: Wed, 12 Feb 2003 17:56:00 -0000 Message-ID: <20030212175600.5461.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Subject: Re: optimization/9654: extra-precision fp comparisons are less accurate Reply-To: X-SW-Source: 2003-02/txt/msg00531.txt.bz2 List-Id: The following reply was made to PR optimization/9654; it has been noted by GNATS. From: To: richard@wetafx.co.nz, gcc-gnats@gcc.gnu.org, gcc-bugs@gcc.gnu.org Cc: Subject: Re: optimization/9654: extra-precision fp comparisons are less accurate Date: Wed, 12 Feb 2003 17:49:17 +0000 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9654 I think it's very dangerous to assume that acos(something-nearly-equal-to-1) won't return 0, or, more importantly sin (acos(something-nearly-equal-to-1) won't. A simple test after the assignment of o would suffice to avoid this problem, eg: #include double s(double t) throw() { double d = 0.75+t; double o = d < 1.0 ? acos(d) : 1.0/67108864.0; if (o == 0.0) o = 1.0 / 67108864.0; return sin(o*0.5)/sin(o); } int main(void) { return isnan(s(0.25-1.0/18014398509481984.0)); } If you are really paranoid, then a range check on small o and applying L'Hoptial's Rule might not be a bad idea. I really don't think you'd like the alternatives to -ffloat-store any more than you like -ffloat-store.