[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] ticket 87, floating point comparison
From: |
Arend Bayer |
Subject: |
Re: [gnugo-devel] ticket 87, floating point comparison |
Date: |
Wed, 8 Feb 2006 17:49:31 +0100 (CET) |
Hi Alain,
> http://trac.gnugo.org/gnugo/ticket/87 has been closed as a "won't fix"
>
> One thing i can do is a fixing patch, replacing all unreliable floating
> equality test by safe inequality tests:
> if (a == b)
> replaced by
> epilon=0.000001
> if (abs(a-b) <= epsilon)
>
> Should i use gg_abs instead of abs ?
I think it is better for readability to leave it as it is; I have reviewed
the complaints and these comparisons are in fact all safe (*). For example,
consider:
if (q->white_strength[ii] == 0.0)
The array white_strength is initialized to 0. Then some of the fields
are set to some numbers like 100.0 or 60.0. A field that was set to
s.th. non-zero will always compare unequal to zero, whereas s.th. left
unchanged will always compare equal to 0.0.
Arend
(*) With the exception 'if (white_score == black_score)' which only affects
debugging output (and only marginally so).