This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: double error
- From: Andreas Conz <andreasc at neuro dot informatik dot uni-kassel dot de>
- To: Bob Hou <yhou at YorkU dot CA>
- Cc: gcc at gnu dot org, <gcc at gcc dot gnu dot org>
- Date: Fri, 31 Jan 2003 19:07:34 +0100 (NFT)
- Subject: Re: double error
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