From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13597 invoked by alias); 31 Jan 2003 18:02:15 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 13573 invoked from network); 31 Jan 2003 18:02:14 -0000 Received: from unknown (HELO fencepost.gnu.org) (199.232.76.164) by 172.16.49.205 with SMTP; 31 Jan 2003 18:02:14 -0000 Received: from monty-python.gnu.org ([199.232.76.173]) by fencepost.gnu.org with esmtp (Exim 4.10) id 18efUU-0007Xq-00 for gcc@gnu.org; Fri, 31 Jan 2003 13:02:14 -0500 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10.13) id 18efUC-0005ga-00 for gcc@gnu.org; Fri, 31 Jan 2003 13:01:57 -0500 Received: from nick-5.neuro.informatik.uni-kassel.de ([141.51.188.31]) by monty-python.gnu.org with esmtp (Exim 4.10.13) id 18efSY-0004Ka-00 for gcc@gnu.org; Fri, 31 Jan 2003 13:00:14 -0500 Received: from nick-5.neuro.informatik.uni-kassel.de (nick-5.neuro.informatik.uni-kassel.de [141.51.188.31]) by nick-5.neuro.informatik.uni-kassel.de (8.12.2/8.12.2) with ESMTP id h0VI7YKl018924; Fri, 31 Jan 2003 19:07:34 +0100 Date: Fri, 31 Jan 2003 19:12:00 -0000 From: Andreas Conz To: Bob Hou cc: gcc@gnu.org, Subject: Re: double error In-Reply-To: <3E3AB250.E768304D@yorku.ca> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-6.3 required=5.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, SPAM_PHRASE_00_01 version=2.41 X-Spam-Level: X-SW-Source: 2003-01/txt/msg01787.txt.bz2 Message-ID: <20030131191200.Fum57oEBceROp9q3QKJnVHyMD5BpzseN-GbvgrJBB9s@z> On Fri, 31 Jan 2003, Bob Hou wrote: Hi Bob, you have hit a typical floatingpoint user error. This are doubles, not real numbers! for doubles a,b,c: it could be that a+b+c != c+b+a Take a look at the following link from the "GCC Further Reading: page: http://www.validlab.com/goldberg/paper.pdf > Hi, > I have the following simple code and expect the results are all the > same. > However the output is following: (The code is compiled with gcc under > Redhat8.0. ) > > The result is : 0 > The result is : 0 > The result is : -2.22045e-15 This is the same. > The code is also tested on MS VS6.0 > and it give the same answers (zero). You could get different results at different optimisation levels at different compilers. > Could you tell me whether it's a bug or I did sth wrong? > Thanks, mit freundliche Gruessen / kind regards Andreas Conz WWW http://www.neuro.informatik.uni-kassel.de/~andreasc e-mail andreasc@neuro.informatik.uni-kassel.de