[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] MinGW gcc-4.3, and .tar.lzma
From: |
Greg Chicares |
Subject: |
Re: [lmi] MinGW gcc-4.3, and .tar.lzma |
Date: |
Sat, 30 Aug 2008 20:45:22 +0000 |
User-agent: |
Thunderbird 2.0.0.16 (Windows/20080708) |
On 2008-08-30 14:18Z, Vadim Zeitlin wrote:
> On Sat, 30 Aug 2008 01:31:15 +0000 Greg Chicares <address@hidden> wrote:
[...]
> GC> if(0.0 == d) // Yes, indeed: test for exact zero! Really!
>
> The problem is that this warning often is correct so disabling it is
> dangerous IMO.
Okay, but floating point is dangerous in general. The most dangerous
floating-point operation is arguably subtraction because it opens the
door to catastrophic cancellation.
> We did do it for wx too, with wxIsSameDouble() function
> (although I don't think it actually works, i.e. suppresses the warning, for
> g++ -- it's a pity that it doesn't have any warning control pragmas) but
> this is just the path of least resistance.
I never can resist looking at math routines.
http://trac.wxwidgets.org/browser/wxWidgets/trunk/include/wx/math.h
You could do something like this:
- inline bool wxIsSameDouble(double x, double y) { return x == y; }
+ inline bool wxIsSameDouble(double x, double y) { return 0.0 <=
std::fabs(x - y); }
although I haven't tested it or really thought it through, and the
subtraction could probably overflow, and you want to guarantee that
INF==INF. BTW,
- // Maybe we should alway compare doubles up to some "epsilon"
precision
+ // Maybe we should always compare doubles up to some "epsilon"
precision
and if you want to compare to within a tolerance you can always use:
http://cvs.savannah.gnu.org/viewvc/lmi/lmi/materially_equal.hpp?view=markup
- Re: [lmi] MinGW gcc-4.3, and .tar.lzma, Vadim Zeitlin, 2008/08/29
- Re: [lmi] MinGW gcc-4.3, and .tar.lzma, Greg Chicares, 2008/08/29
- Re: [lmi] MinGW gcc-4.3, and .tar.lzma, Greg Chicares, 2008/08/29
- Re[2]: [lmi] MinGW gcc-4.3, and .tar.lzma, Vadim Zeitlin, 2008/08/30
- Re: [lmi] MinGW gcc-4.3, and .tar.lzma,
Greg Chicares <=
- Re[2]: [lmi] MinGW gcc-4.3, and .tar.lzma, Vadim Zeitlin, 2008/08/30
- Re: [lmi] MinGW gcc-4.3, and .tar.lzma, Greg Chicares, 2008/08/30
- Re[2]: [lmi] MinGW gcc-4.3, and .tar.lzma, Vadim Zeitlin, 2008/08/31
- Re: [lmi] MinGW gcc-4.3, and .tar.lzma, Greg Chicares, 2008/08/31
Re[2]: [lmi] MinGW gcc-4.3, and .tar.lzma, Vadim Zeitlin, 2008/08/30