Dear GNU Chess user,

Thank you very much for your reports. I will look into this as soon as
possible. Please note that the
last version of the package is 6.3.0, although I am not sure it will make a
difference as far as your
bug reports are concerned.

Best regards,
Antonio Ceballos


On Sun, Apr 12, 2026 at 4:19 PM 武汉理工大学-周豪 <[email protected]> wrote:

> Dear GNU Chess maintainers,
> I found a division by zero issue in version 6.2.9.
>
> File: src/frontend/players.cc
> Function: rscorecompare
>
> The function calculates score as:
> ascore = (a->wins + (a->draws / 2)) / (a->wins + a->draws + a->losses);
>
> If a player has no games (wins = draws = losses = 0), the denominator is
> 0, causing division by zero.
>
> Suggested fix:
>
> static int rscorecompare(const void *aa, const void *bb)
> {
>     const playerentry *a = (const playerentry *)aa;
>     const playerentry *b = (const playerentry *)bb;
>     float ascore, bscore;
>     int a_total = a->wins + a->draws + a->losses;
>     int b_total = b->wins + b->draws + b->losses;
>     if (a_total == 0) ascore = 0.0f;
>     else ascore = (a->wins + (a->draws / 2.0f)) / a_total;
>     if (b_total == 0) bscore = 0.0f;
>     else bscore = (b->wins + (b->draws / 2.0f)) / b_total;
>     if (ascore > bscore) return -1;
>     else if (bscore > ascore) return 1;
>     else return 0;
> }
>
> Please let me know if you need any more information.
>
> Best regards
>
>

Reply via email to