Re: make check errors on linux



On 11 Jan 2001 16:18:41 +0000, 
"Daniel" == Daniel Barlow <dan noetbook telent net> wrote:

Daniel> Michael Meeks <michael helixcode com> writes:
>> > Comparing floats with == is a dumb mistake :-)
>> 
>> Well; you seem to be right, however no manipulaton is done on the
>> floats, they are simply copied from a to b and then compared. ie if:
>> 
>> double a = 3.5, b;
>> b = a;
>> g_assert (a == b);
>> 
>> fails; then something strange is happening.

Daniel> x86 has 80-bit floating point registers, or somesuch?  If one of
Daniel> these gets into a register and the other's in RAM, what's the betting
Daniel> that they'll compare unequal?

(as far as I know, all comparisons are done in registers, so the point
doesn't apply). 

Anyway, I can imagin this happening as the result of some optimizations. The
typical way of doing this would be g_assert( ABS(a - b) < TOLERANCE), where
TOLERANCE is of the order of the 1e-307 (i.e., just a bit bigger than DBL_MIN
in /usr/include/limits.h).

Also, there is a difference (in bit pattern) between +0.0 and -0.0, and
lastly, if both a and b are (+-)Infintity or NaN (Not a Number, i.e., 0.0/0.0
etc), then any comparison returns 0 (although you typically have a floating
point exception before that time).

Cheers,
                                                                      Philip
-- 
Vegetarians eat vegetables. Beware the humanitarians (anon.)
-----------------------------------------------------------------------------
Philip Lijnzaad, lijnzaad ebi ac uk \ European Bioinformatics Institute,rm A2-08
+44 (0)1223 49 4639                 / Wellcome Trust Genome Campus, Hinxton
+44 (0)1223 49 4468 (fax)           \ Cambridgeshire CB10 1SD,  GREAT BRITAIN
PGP fingerprint: E1 03 BF 80 94 61 B6 FC  50 3D 1F 64 40 75 FB 53




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