Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] Floating point exception
Home

[Freeciv-Dev] Floating point exception

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Floating point exception
From: Lobo Gris <molv@xxxxxxxxxxxxx>
Date: Tue, 22 Jul 2003 05:00:38 -0300
Reply-to: molv@xxxxxxxxxxxxx

A sinchronous floating point exception is generated in the server (I have saved 
a game that always produce the exception when I run a new turn)

Here is the gdb message:

-------------------------------------------------
Program received signal SIGFPE, Arithmetic exception.
0x80c32ad in kill_desire (benefit=30, attack=0, loss=10, vuln=0, 
    victim_count=2) at aiunit.c:944
944       desire = ((benefit * attack - loss * vuln) * victim_count * 
SHIELD_WEIGHTING
-------------------------------------------------

The complete function where the exception produces is:

----------------------------------------------------------
int kill_desire(int benefit, int attack, int loss, int vuln, int victim_count)
{
  int desire;

  /*         attractiveness     danger */
  desire = ((benefit * attack - loss * vuln) * victim_count * SHIELD_WEIGHTING
            / (attack + vuln * victim_count));

  return desire;
}
----------------------------------------------------------

So there is a "divided by zero" exception because attack and vuln are 0 at the 
same time.



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