[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: [lmi] MinGW gcc-4.3, and .tar.lzma

From: Vadim Zeitlin
Subject: Re[2]: [lmi] MinGW gcc-4.3, and .tar.lzma
Date: Sat, 30 Aug 2008 23:09:14 +0200

On Sat, 30 Aug 2008 20:45:22 +0000 Greg Chicares <address@hidden> wrote:

GC> On 2008-08-30 14:18Z, Vadim Zeitlin wrote:
GC> > On Sat, 30 Aug 2008 01:31:15 +0000 Greg Chicares <address@hidden> wrote:
GC> [...]
GC> > GC>   if(0.0 == d) // Yes, indeed: test for exact zero! Really!
GC> > 
GC> >  The problem is that this warning often is correct so disabling it is
GC> > dangerous IMO.
GC> Okay, but floating point is dangerous in general.

 True, this is why I prefer never using it. This is only part a joke: IME
most of the things that the floating point is used for would be better done
using a fixed precision decimal class or a rational class.

GC> You could do something like this:
GC> -        inline bool wxIsSameDouble(double x, double y) { return x == y; }
GC> +        inline bool wxIsSameDouble(double x, double y) { return 0.0 <= 
std::fabs(x - y); }
GC> although I haven't tested it or really thought it through, and the
GC> subtraction could probably overflow, and you want to guarantee that

 wxIsSameDouble() was just a mechanical refactoring of code which used x==y
in several different places (and so provoked several different warnings). I
guess to understand how it really should be implement we must look at each
of them and understand what should be done for INF and for NaN...

GC> -            //     Maybe we should alway compare doubles up to some 
"epsilon" precision
GC> +            //     Maybe we should always compare doubles up to some 
"epsilon" precision

 Fixed, thanks.

GC> and if you want to compare to within a tolerance you can always use:

 This is going to be useful, thanks! I assume I have your permission to use
it under wx licence and not GPL?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]