[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Infinite loop with GCC 4.3
From: |
Han-Wen Nienhuys |
Subject: |
Re: Infinite loop with GCC 4.3 |
Date: |
Mon, 26 May 2008 10:44:56 -0300 |
2008/5/26 Joe Neeman <address@hidden>:
> On Mon, 2008-05-26 at 10:09 +0200, Mats Bengtsson wrote:
>> As is taught in any course on numerical methods, you should always be
>> very careful with
>> comparing numerical values. For example you should use tests of the form
>> if (abs(x-y) < epsilon)
>> instead of
>> if (x==y)
>> where epsilon is a fixed value somewhat larger than machine precisions.
As others have pointed out, this is not really the problem here, but if you see
if (abs(x-y) < eps)
you should be very suspicious; since eps is a constant, this code
depends on x and y always having roughly the same exponent. Eg. this
will fail erroneously if x=0.999999999e10 and y=1.0e10. For these
computations there is no real golden rule, except to use your brain,
and do an analysis of what is appropriate
--
Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen
- Re: Infinite loop with GCC 4.3, (continued)
- Re: Infinite loop with GCC 4.3, Trevor Daniels, 2008/05/26
- Re: Infinite loop with GCC 4.3, Han-Wen Nienhuys, 2008/05/26
- RE: Infinite loop with GCC 4.3, Carl D. Sorensen, 2008/05/26
- Re: Infinite loop with GCC 4.3, Mats Bengtsson, 2008/05/26
- Re: Infinite loop with GCC 4.3, Joe Neeman, 2008/05/26
- Re: Infinite loop with GCC 4.3, Graham Percival, 2008/05/26
- Re: Infinite loop with GCC 4.3,
Han-Wen Nienhuys <=
- Re: Infinite loop with GCC 4.3, Trevor Daniels, 2008/05/26