Bill Allombert on Wed, 10 Nov 1999 23:01:48 +0100 (MET)


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

bug in padic_sqrt


The bug is
? (5+3*I)+O(5^-18)
  ***   segmentation fault: bug in GP (please report).

? sqrt(O(5^-18))
%1 = O(5^-9)
? \x
[&=0049af04] PADIC!0f000005  00007ff7  0049af18  0049af24  0049af48
*   p : [&=0049af18] INT|02000003  40000003  00000005
  p^l : [&=0049af24] FRAC|08000003  0049af30  0049af3c
    num = [&=0049af30] INT|02000003  40000003  00000001
    den = [&=0049af3c] INT|02000003  40000003  001dcd65
    I : [&=0049af48] INT|02000002  00000002

p^l should never be a t_FRAC since l must be >=0

here a patch.

Now
? (5+3*I)+O(5^-18)
%4 = O(5^-18)
which I expect is "correct".


(CVS version updated)

Index: src/basemath/trans1.c
===================================================================
RCS file: /home/megrez/cvsroot/pari/src/basemath/trans1.c,v
retrieving revision 1.7
diff -u -r1.7 trans1.c
--- src/basemath/trans1.c       1999/10/31 17:59:44     1.7
+++ src/basemath/trans1.c       1999/11/10 21:57:52
@@ -636,7 +636,7 @@
   if (gcmp0(x))
   {
     y[4] = zero; e = (e+1)>>1;
-    y[3] = lpuigs((GEN)x[2],e);
+    y[3] = un;
     y[1] = evalvalp(e) | evalprecp(precp(x));
     return y;
   }