Karim BELABAS on Thu, 6 May 1999 17:27:32 +0200 (MET DST)


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

Re: Divide by zero


[Bill Daly:]
> I had a divide-by-zero bug in GP which PARI didn't report as an error.
> Out of curiosity, I typed the expression (3-3)/(2-2) on the GP command
> line, and PARI reported to answer as 0, rather than signalling a
> divide-by-zero error. This looks like a bit of excessive optimization.

Right. Here's a simple fix (2.0.14).
  
   Karim.

*** src/basemath/gen1.c.orig    Mon May  3 18:59:46 1999
--- src/basemath/gen1.c Thu May  6 17:21:36 1999
***************
*** 1390,1395 ****
--- 1390,1396 ----
      switch (signe(x))
      {
        case 0:
+         if (gcmp0(y)) err(gdiver2);
          if (ty != t_INTMOD) return gzero;
          z = cgetg(3,t_INTMOD); icopyifstack(y[1],z[1]); z[2]=zero;
          return z;

__
Karim Belabas                    email: Karim.Belabas@math.u-psud.fr
Dep. de Mathematiques, Bat. 425
Universite Paris-Sud             Tel: (00 33) 1 69 15 57 48
F-91405 Orsay (France)           Fax: (00 33) 1 69 15 60 19
--
PARI/GP Home Page: http://hasse.mathematik.tu-muenchen.de/ntsw/pari/