Karim Belabas on Thu, 29 Jan 2004 13:03:00 +0100

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

Re: Bug?

* McLaughlin, James [2004-01-29 01:44]:
> That worked, thanks. 
> A little curious, since I used the old code for some time on the old version
> (2.1.4).

In 2.1.*, poldegree(0) was -1. In 2.2.* it was changed to a huge negative
value. Some reasons:

* prevents unnecessary hackish code ( if (poldegree(x) == -1), with a magic
constant "-1", instead of the better if (poldegree(x) < 0) ). I hope nobody
will want to spell out explicitly poldegree(x) == -2147483647 (which is not
portable, by the way).

* makes hunting for bugs easier: huge constants appearing out of nowhere are a
tell-tale for forgotten special cases (e.g valuation(0) or poldegree(0)). 
They are also liable to break incorrect code cleanly and immediately, instead
of long after the problem occurred or in seemingly random ways.

* makes poldegree() consistent with valuation()

* more useful in the context of rational functions: now 0 has a lower 
degree than any non-zero rational function. Before, one would have 
poldegree(0) == poldegree(1/x) )

Besides that, you in fact spotted a bug: the stack overflow should have been a

   *** power overflow in pow_monome

[ making the problem easier to spot, esp. if "trap" is activated ]. That was
due to a C-long overflow in the code.

Karim Belabas                     Tel: (+33) (0)1 69 15 57 48
Dep. de Mathematiques, Bat. 425   Fax: (+33) (0)1 69 15 60 19
Universite Paris-Sud              http://www.math.u-psud.fr/~belabas/ 
F-91405 Orsay (France)            http://pari.math.u-bordeaux.fr/  [PARI/GP]