This is the mail archive of the gcc@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: 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




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