Code coverage tests

This page documents the degree to which the PARI/GP source code is tested by our public test suite, distributed with the source distribution in directory src/test/. This is measured by the gcov utility; we then process gcov output using the lcov frond-end.

We test a few variants depending on Configure flags on the pari.math.u-bordeaux.fr machine (x86_64 architecture), and agregate them in the final report:

The target is 90% coverage for all mathematical modules (given that branches depending on DEBUGLEVEL or DEBUGMEM are not covered). This script is run to produce the results below.

LCOV - code coverage report
Current view: top level - kernel/none - mp_indep.c (source / functions) Hit Total Coverage
Test: PARI/GP v2.8.0 lcov report (development 19350-bd5f220) Lines: 513 558 91.9 %
Date: 2016-08-24 06:11:24 Functions: 50 52 96.2 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : #line 2 "../src/kernel/none/mp_indep.c"
       2             : /* Copyright (C) 2000  The PARI group.
       3             : 
       4             : This file is part of the PARI/GP package.
       5             : 
       6             : PARI/GP is free software; you can redistribute it and/or modify it under the
       7             : terms of the GNU General Public License as published by the Free Software
       8             : Foundation. It is distributed in the hope that it will be useful, but WITHOUT
       9             : ANY WARRANTY WHATSOEVER.
      10             : 
      11             : Check the License for details. You should have received a copy of it, along
      12             : with the package; see the file 'COPYING'. If not, write to the Free Software
      13             : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */
      14             : 
      15             : /* Find c such that 1=c*b mod 2^BITS_IN_LONG, assuming b odd (unchecked) */
      16             : ulong
      17    23253725 : invmod2BIL(ulong b)
      18             : {
      19             :   static int tab[] = { 0, 0, 0, 8, 0, 8, 0, 0 };
      20    23253725 :   ulong x = b + tab[b & 7]; /* b^(-1) mod 2^4 */
      21             : 
      22             :   /* Newton applied to 1/x - b = 0 */
      23             : #ifdef LONG_IS_64BIT
      24    23253725 :   x = x*(2-b*x); /* one more pass necessary */
      25             : #endif
      26    23253725 :   x = x*(2-b*x);
      27    23253725 :   x = x*(2-b*x); return x*(2-b*x);
      28             : }
      29             : 
      30             : void
      31  1242280342 : affrr(GEN x, GEN y)
      32             : {
      33             :   long lx,ly,i;
      34             : 
      35  1242280342 :   y[1] = x[1]; if (!signe(x)) return;
      36             : 
      37  1235049863 :   lx=lg(x); ly=lg(y);
      38  1235049863 :   if (lx <= ly)
      39             :   {
      40  1177017152 :     for (i=2; i<lx; i++) y[i]=x[i];
      41  1177017152 :     for (   ; i<ly; i++) y[i]=0;
      42  1177017152 :     return;
      43             :   }
      44    58032711 :   for (i=2; i<ly; i++) y[i]=x[i];
      45             :   /* lx > ly: round properly */
      46    58032711 :   if (x[ly] & HIGHBIT) roundr_up_ip(y, ly);
      47             : }
      48             : 
      49             : GEN
      50     5980912 : trunc2nr(GEN x, long n)
      51             : {
      52             :   long ex;
      53     5980912 :   if (!signe(x)) return gen_0;
      54     5946805 :   ex = expo(x) + n; if (ex < 0) return gen_0;
      55     5671611 :   return mantissa2nr(x, ex - bit_prec(x) + 1);
      56             : }
      57             : 
      58             : /* x a t_REAL, x = i/2^e, i a t_INT */
      59             : GEN
      60    17163945 : mantissa_real(GEN x, long *e)
      61             : {
      62    17163945 :   *e = bit_prec(x)-1-expo(x);
      63    17163945 :   return mantissa2nr(x, 0);
      64             : }
      65             : 
      66             : GEN
      67  1085209045 : mului(ulong x, GEN y)
      68             : {
      69  1085209045 :   long s = signe(y);
      70             :   GEN z;
      71             : 
      72  1085209045 :   if (!s || !x) return gen_0;
      73  1030399075 :   z = muluispec(x, y+2, lgefint(y)-2);
      74  1026454260 :   setsigne(z,s); return z;
      75             : }
      76             : 
      77             : GEN
      78   132389147 : mulsi(long x, GEN y)
      79             : {
      80   132389147 :   long s = signe(y);
      81             :   GEN z;
      82             : 
      83   132389147 :   if (!s || !x) return gen_0;
      84    95259503 :   if (x<0) { s = -s; x = -x; }
      85    95259503 :   z = muluispec((ulong)x, y+2, lgefint(y)-2);
      86    95259500 :   setsigne(z,s); return z;
      87             : }
      88             : 
      89             : GEN
      90    29964614 : mulss(long x, long y)
      91             : {
      92             :   long p1;
      93             :   LOCAL_HIREMAINDER;
      94             : 
      95    29964614 :   if (!x || !y) return gen_0;
      96    29868014 :   if (x<0) {
      97       59626 :     x = -x;
      98       59626 :     if (y<0) { y = -y; p1 = mulll(x,y); return uutoi(hiremainder, p1); }
      99       59626 :     p1 = mulll(x,y); return uutoineg(hiremainder, p1);
     100             :   } else {
     101    29808388 :     if (y<0) { y = -y; p1 = mulll(x,y); return uutoineg(hiremainder, p1); }
     102    29807897 :     p1 = mulll(x,y); return uutoi(hiremainder, p1);
     103             :   }
     104             : }
     105             : GEN
     106        4159 : sqrs(long x)
     107             : {
     108             :   long p1;
     109             :   LOCAL_HIREMAINDER;
     110             : 
     111        4159 :   if (!x) return gen_0;
     112        4159 :   if (x<0) x = -x;
     113        4159 :   p1 = mulll(x,x); return uutoi(hiremainder, p1);
     114             : }
     115             : GEN
     116  1666358056 : muluu(ulong x, ulong y)
     117             : {
     118             :   long p1;
     119             :   LOCAL_HIREMAINDER;
     120             : 
     121  1666358056 :   if (!x || !y) return gen_0;
     122  1666316182 :   p1 = mulll(x,y); return uutoi(hiremainder, p1);
     123             : }
     124             : GEN
     125   589851124 : sqru(ulong x)
     126             : {
     127             :   long p1;
     128             :   LOCAL_HIREMAINDER;
     129             : 
     130   589851124 :   if (!x) return gen_0;
     131   589814389 :   p1 = mulll(x,x); return uutoi(hiremainder, p1);
     132             : }
     133             : 
     134             : /* assume x > 1, y != 0. Return u * y with sign s */
     135             : static GEN
     136   453921535 : mulur_2(ulong x, GEN y, long s)
     137             : {
     138   453921535 :   long m, sh, i, lx = lg(y), e = expo(y);
     139   453921535 :   GEN z = cgetr(lx);
     140             :   ulong garde;
     141             :   LOCAL_HIREMAINDER;
     142             : 
     143   453921535 :   y--; garde = mulll(x,y[lx]);
     144   453921535 :   for (i=lx-1; i>=3; i--) z[i]=addmul(x,y[i]);
     145   453921535 :   z[2]=hiremainder; /* != 0 since y normalized and |x| > 1 */
     146   453921535 :   sh = bfffo(hiremainder); m = BITS_IN_LONG-sh;
     147   453921535 :   if (sh) shift_left(z,z, 2,lx-1, garde,sh);
     148   453921535 :   z[1] = evalsigne(s) | evalexpo(m+e);
     149   453921535 :   if ((garde << sh) & HIGHBIT) roundr_up_ip(z, lx);
     150   453921535 :   return z;
     151             : }
     152             : 
     153             : INLINE GEN
     154     1144516 : mul0r(GEN x)
     155             : {
     156     1144516 :   long l = lg(x), e = expo(x);
     157     1144516 :   e = (l > 2)? -prec2nbits(l) + e: (e < 0? 2*e: 0);
     158     1144516 :   return real_0_bit(e);
     159             : }
     160             : /* lg(x) > 2 */
     161             : INLINE GEN
     162       90594 : div0r(GEN x) {
     163       90594 :   long l = lg(x), e = expo(x);
     164       90594 :   return real_0_bit(-prec2nbits(l) - e);
     165             : }
     166             : 
     167             : GEN
     168    37389680 : mulsr(long x, GEN y)
     169             : {
     170             :   long s;
     171             : 
     172    37389680 :   if (!x) return mul0r(y);
     173    36372300 :   s = signe(y);
     174    36372300 :   if (!s)
     175             :   {
     176       51986 :     if (x < 0) x = -x;
     177       51986 :     return real_0_bit( expo(y) + expu(x) );
     178             :   }
     179    36320314 :   if (x==1)  return rcopy(y);
     180    35853989 :   if (x==-1) return negr(y);
     181    34901210 :   if (x < 0)
     182    21453953 :     return mulur_2((ulong)-x, y, -s);
     183             :   else
     184    13447257 :     return mulur_2((ulong)x, y, s);
     185             : }
     186             : 
     187             : GEN
     188   463444819 : mulur(ulong x, GEN y)
     189             : {
     190             :   long s;
     191             : 
     192   463444819 :   if (!x) return mul0r(y);
     193   463444819 :   s = signe(y);
     194   463444819 :   if (!s) return real_0_bit( expo(y) + expu(x) );
     195   461805180 :   if (x==1) return rcopy(y);
     196   419020325 :   return mulur_2(x, y, s);
     197             : }
     198             : 
     199             : INLINE void
     200   997567613 : mulrrz_end(GEN z, GEN hi, long lz, long sz, long ez, ulong garde)
     201             : {
     202             :   long i;
     203   997567613 :   if (hi[2] < 0)
     204             :   {
     205   452157483 :     if (z != hi)
     206    30002955 :       for (i=2; i<lz ; i++) z[i] = hi[i];
     207   452157483 :     ez++;
     208             :   }
     209             :   else
     210             :   {
     211   545410130 :     shift_left(z,hi,2,lz-1, garde, 1);
     212   545410130 :     garde <<= 1;
     213             :   }
     214   997567613 :   if (garde & HIGHBIT)
     215             :   { /* round to nearest */
     216   488451874 :     i = lz; do ((ulong*)z)[--i]++; while (i>1 && z[i]==0);
     217   488451874 :     if (i == 1) { z[2] = (long)HIGHBIT; ez++; }
     218             :   }
     219   997567613 :   z[1] = evalsigne(sz)|evalexpo(ez);
     220   997567613 : }
     221             : /* mulrrz_end for lz = 3, minor simplifications. z[2]=hiremainder from mulll */
     222             : INLINE void
     223  1357737588 : mulrrz_3end(GEN z, long sz, long ez, ulong garde)
     224             : {
     225  1357737588 :   if (z[2] < 0)
     226             :   { /* z2 < (2^BIL-1)^2 / 2^BIL, hence z2+1 != 0 */
     227   749155245 :     if (garde & HIGHBIT) z[2]++; /* round properly */
     228   749155245 :     ez++;
     229             :   }
     230             :   else
     231             :   {
     232   608582343 :     uel(z,2) = (uel(z,2)<<1) | (garde>>(BITS_IN_LONG-1));
     233   608582343 :     if (garde & (1UL<<(BITS_IN_LONG-2)))
     234             :     {
     235   291101340 :       uel(z,2)++; /* round properly, z2+1 can overflow */
     236   291101340 :       if (!uel(z,2)) { uel(z,2) = HIGHBIT; ez++; }
     237             :     }
     238             :   }
     239  1357737588 :   z[1] = evalsigne(sz)|evalexpo(ez);
     240  1357737588 : }
     241             : 
     242             : /* set z <-- x^2 != 0, floating point multiplication.
     243             :  * lz = lg(z) = lg(x) */
     244             : INLINE void
     245    71115694 : sqrz_i(GEN z, GEN x, long lz)
     246             : {
     247    71115694 :   long ez = 2*expo(x);
     248             :   long i, j, lzz, p1;
     249             :   ulong garde;
     250             :   GEN x1;
     251             :   LOCAL_HIREMAINDER;
     252             :   LOCAL_OVERFLOW;
     253             : 
     254    71115694 :   if (lz > MULRR_MULII_LIMIT)
     255             :   {
     256     4289858 :     pari_sp av = avma;
     257     4289858 :     GEN hi = sqrispec_mirror(x+2, lz-2);
     258     4289858 :     mulrrz_end(z, hi, lz, 1, ez, hi[lz]);
     259     4289858 :     avma = av; return;
     260             :   }
     261    66825836 :   if (lz == 3)
     262             :   {
     263    10957653 :     garde = mulll(x[2],x[2]);
     264    10957653 :     z[2] = hiremainder;
     265    10957653 :     mulrrz_3end(z, 1, ez, garde);
     266    10957653 :     return;
     267             :   }
     268             : 
     269    55868183 :   lzz = lz-1; p1 = x[lzz];
     270    55868183 :   if (p1)
     271             :   {
     272    49569069 :     (void)mulll(p1,x[3]);
     273    49569069 :     garde = addmul(p1,x[2]);
     274    49569069 :     z[lzz] = hiremainder;
     275             :   }
     276             :   else
     277             :   {
     278     6299114 :     garde = 0;
     279     6299114 :     z[lzz] = 0;
     280             :   }
     281   178311985 :   for (j=lz-2, x1=x-j; j>=3; j--)
     282             :   {
     283   122443802 :     p1 = x[j]; x1++;
     284   122443802 :     if (p1)
     285             :     {
     286   118976495 :       (void)mulll(p1,x1[lz+1]);
     287   118976495 :       garde = addll(addmul(p1,x1[lz]), garde);
     288   497686559 :       for (i=lzz; i>j; i--)
     289             :       {
     290   378710064 :         hiremainder += overflow;
     291   378710064 :         z[i] = addll(addmul(p1,x1[i]), z[i]);
     292             :       }
     293   118976495 :       z[j] = hiremainder+overflow;
     294             :     }
     295     3467307 :     else z[j]=0;
     296             :   }
     297    55868183 :   p1 = x[2]; x1++;
     298    55868183 :   garde = addll(mulll(p1,x1[lz]), garde);
     299   234180168 :   for (i=lzz; i>2; i--)
     300             :   {
     301   178311985 :     hiremainder += overflow;
     302   178311985 :     z[i] = addll(addmul(p1,x1[i]), z[i]);
     303             :   }
     304    55868183 :   z[2] = hiremainder+overflow;
     305    55868183 :   mulrrz_end(z, z, lz, 1, ez, garde);
     306             : }
     307             : 
     308             : /* lz "large" = lg(y) = lg(z), lg(x) > lz if flag = 1 and >= if flag = 0 */
     309             : INLINE void
     310    61039760 : mulrrz_int(GEN z, GEN x, GEN y, long lz, long flag, long sz)
     311             : {
     312    61039760 :   pari_sp av = avma;
     313    61039760 :   GEN hi = muliispec_mirror(y+2, x+2, lz+flag-2, lz-2);
     314    61039760 :   mulrrz_end(z, hi, lz, sz, expo(x)+expo(y), hi[lz]);
     315    61039760 :   avma = av;
     316    61039760 : }
     317             : 
     318             : /* lz = 3 */
     319             : INLINE void
     320  1346779935 : mulrrz_3(GEN z, GEN x, GEN y, long flag, long sz)
     321             : {
     322             :   ulong garde;
     323             :   LOCAL_HIREMAINDER;
     324  1346779935 :   if (flag)
     325             :   {
     326    14252221 :     (void)mulll(x[2],y[3]);
     327    14252221 :     garde = addmul(x[2],y[2]);
     328             :   }
     329             :   else
     330  1332527714 :     garde = mulll(x[2],y[2]);
     331  1346779935 :   z[2] = hiremainder;
     332  1346779935 :   mulrrz_3end(z, sz, expo(x)+expo(y), garde);
     333  1346779935 : }
     334             : 
     335             : /* set z <-- x*y, floating point multiplication. Trailing 0s for x are
     336             :  * treated efficiently (important application: mulir).
     337             :  * lz = lg(z) = lg(x) <= ly <= lg(y), sz = signe(z). flag = lg(x) < lg(y) */
     338             : INLINE void
     339  2283352607 : mulrrz_i(GEN z, GEN x, GEN y, long lz, long flag, long sz)
     340             : {
     341             :   long ez, i, j, lzz, p1;
     342             :   ulong garde;
     343             :   GEN y1;
     344             :   LOCAL_HIREMAINDER;
     345             :   LOCAL_OVERFLOW;
     346             : 
     347  2283352607 :   if (x == y) { sqrz_i(z,x,lz); return; }
     348  2283352607 :   if (lz > MULRR_MULII_LIMIT) { mulrrz_int(z,x,y,lz,flag,sz); return; }
     349  2222312847 :   if (lz == 3) { mulrrz_3(z,x,y,flag,sz); return; }
     350   875532912 :   ez = expo(x) + expo(y);
     351   875532912 :   if (flag) { (void)mulll(x[2],y[lz]); garde = hiremainder; } else garde = 0;
     352   875532912 :   lzz=lz-1; p1=x[lzz];
     353   875532912 :   if (p1)
     354             :   {
     355   843730362 :     (void)mulll(p1,y[3]);
     356   843730362 :     garde = addll(addmul(p1,y[2]), garde);
     357   843730362 :     z[lzz] = overflow+hiremainder;
     358             :   }
     359    31802550 :   else z[lzz]=0;
     360  2736445247 :   for (j=lz-2, y1=y-j; j>=3; j--)
     361             :   {
     362  1860912335 :     p1 = x[j]; y1++;
     363  1860912335 :     if (p1)
     364             :     {
     365  1801628886 :       (void)mulll(p1,y1[lz+1]);
     366  1801628886 :       garde = addll(addmul(p1,y1[lz]), garde);
     367  7231270396 :       for (i=lzz; i>j; i--)
     368             :       {
     369  5429641510 :         hiremainder += overflow;
     370  5429641510 :         z[i] = addll(addmul(p1,y1[i]), z[i]);
     371             :       }
     372  1801628886 :       z[j] = hiremainder+overflow;
     373             :     }
     374    59283449 :     else z[j]=0;
     375             :   }
     376   875532912 :   p1 = x[2]; y1++;
     377   875532912 :   garde = addll(mulll(p1,y1[lz]), garde);
     378  3611978159 :   for (i=lzz; i>2; i--)
     379             :   {
     380  2736445247 :     hiremainder += overflow;
     381  2736445247 :     z[i] = addll(addmul(p1,y1[i]), z[i]);
     382             :   }
     383   875532912 :   z[2] = hiremainder+overflow;
     384   875532912 :   mulrrz_end(z, z, lz, sz, ez, garde);
     385             : }
     386             : 
     387             : GEN
     388  2307818547 : mulrr(GEN x, GEN y)
     389             : {
     390             :   long flag, ly, lz, sx, sy;
     391             :   GEN z;
     392             : 
     393  2307818547 :   if (x == y) return sqrr(x);
     394  2307716156 :   sx = signe(x); if (!sx) return real_0_bit(expo(x) + expo(y));
     395  2278913916 :   sy = signe(y); if (!sy) return real_0_bit(expo(x) + expo(y));
     396  2268872910 :   if (sy < 0) sx = -sx;
     397  2268872910 :   lz = lg(x);
     398  2268872910 :   ly = lg(y);
     399  2268872910 :   if (lz > ly) { lz = ly; swap(x, y); flag = 1; } else flag = (lz != ly);
     400  2268872910 :   z = cgetr(lz);
     401  2268872910 :   mulrrz_i(z, x,y, lz,flag, sx);
     402  2268872910 :   return z;
     403             : }
     404             : 
     405             : GEN
     406    72391047 : sqrr(GEN x)
     407             : {
     408    72391047 :   long lz, sx = signe(x);
     409             :   GEN z;
     410             : 
     411    72391047 :   if (!sx) return real_0_bit(2*expo(x));
     412    71115694 :   lz = lg(x); z = cgetr(lz);
     413    71115694 :   sqrz_i(z, x, lz);
     414    71115694 :   return z;
     415             : }
     416             : 
     417             : GEN
     418   149087270 : mulir(GEN x, GEN y)
     419             : {
     420   149087270 :   long sx = signe(x), sy;
     421   149087270 :   if (!sx) return mul0r(y);
     422   148960134 :   if (lgefint(x) == 3) {
     423   132475207 :     GEN z = mulur(uel(x,2), y);
     424   132475207 :     if (sx < 0) togglesign(z);
     425   132475207 :     return z;
     426             :   }
     427    16484927 :   sy = signe(y);
     428    16484927 :   if (!sy) return real_0_bit(expi(x) + expo(y));
     429    15316597 :   if (sy < 0) sx = -sx;
     430             :   {
     431    15316597 :     long lz = lg(y), lx = lgefint(x);
     432    15316597 :     GEN hi, z = cgetr(lz);
     433    15316597 :     pari_sp av = avma;
     434    15316597 :     if (lx < (lz>>1) || (lx < lz && lz > MULRR_MULII_LIMIT))
     435             :     { /* size mantissa of x < half size of mantissa z, or lx < lz so large
     436             :        * that mulrr will call mulii anyway: mulii */
     437      836900 :       x = itor(x, lx);
     438      836900 :       hi = muliispec_mirror(y+2, x+2, lz-2, lx-2);
     439      836900 :       mulrrz_end(z, hi, lz, sx, expo(x)+expo(y), hi[lz]);
     440             :     }
     441             :     else /* dubious: complete x with 0s and call mulrr */
     442    14479697 :       mulrrz_i(z, itor(x,lz), y, lz, 0, sx);
     443    15316597 :     avma = av; return z;
     444             :   }
     445             : }
     446             : 
     447             : /* x + y*z, generic. If lgefint(z) <= 3, caller should use faster variants  */
     448             : static GEN
     449    19919154 : addmulii_gen(GEN x, GEN y, GEN z, long lz)
     450             : {
     451    19919154 :   long lx = lgefint(x), ly;
     452             :   pari_sp av;
     453             :   GEN t;
     454    19919154 :   if (lx == 2) return mulii(z,y);
     455    19265369 :   ly = lgefint(y);
     456    19265369 :   if (ly == 2) return icopy(x); /* y = 0, wasteful copy */
     457    19247208 :   av = avma; (void)new_chunk(lx+ly+lz); /*HACK*/
     458    19247208 :   t = mulii(z, y);
     459    19247208 :   avma = av; return addii(t,x);
     460             : }
     461             : /* x + y*z, lgefint(z) == 3 */
     462             : static GEN
     463   231405922 : addmulii_lg3(GEN x, GEN y, GEN z)
     464             : {
     465   231405922 :   long s = signe(z), lx, ly;
     466   231405922 :   ulong w = z[2];
     467             :   pari_sp av;
     468             :   GEN t;
     469   231405922 :   if (w == 1) return (s > 0)? addii(x,y): subii(x,y); /* z = +- 1 */
     470   172250431 :   lx = lgefint(x);
     471   172250431 :   ly = lgefint(y);
     472   172250431 :   if (lx == 2)
     473             :   { /* x = 0 */
     474    30500584 :     if (ly == 2) return gen_0;
     475    25745266 :     t = muluispec(w, y+2, ly-2);
     476    25745266 :     if (signe(y) < 0) s = -s;
     477    25745266 :     setsigne(t, s); return t;
     478             :   }
     479   141749847 :   if (ly == 2) return icopy(x); /* y = 0, wasteful copy */
     480   136456366 :   av = avma; (void)new_chunk(1+lx+ly);/*HACK*/
     481   136456366 :   t = muluispec(w, y+2, ly-2);
     482   136456366 :   if (signe(y) < 0) s = -s;
     483   136456366 :   setsigne(t, s);
     484   136456366 :   avma = av; return addii(x,t);
     485             : }
     486             : /* x + y*z */
     487             : GEN
     488    29862077 : addmulii(GEN x, GEN y, GEN z)
     489             : {
     490    29862077 :   long lz = lgefint(z);
     491    29862077 :   switch(lz)
     492             :   {
     493      259701 :     case 2: return icopy(x); /* z = 0, wasteful copy */
     494    27545034 :     case 3: return addmulii_lg3(x, y, z);
     495     2057342 :     default:return addmulii_gen(x, y, z, lz);
     496             :   }
     497             : }
     498             : /* x + y*z, returns x itself and not a copy when y*z = 0 */
     499             : GEN
     500   757896923 : addmulii_inplace(GEN x, GEN y, GEN z)
     501             : {
     502             :   long lz;
     503   757896923 :   if (lgefint(y) == 2) return x;
     504   221722700 :   lz = lgefint(z);
     505   221722700 :   switch(lz)
     506             :   {
     507           0 :     case 2: return x;
     508   203860888 :     case 3: return addmulii_lg3(x, y, z);
     509    17861812 :     default:return addmulii_gen(x, y, z, lz);
     510             :   }
     511             : }
     512             : 
     513             : /* written by Bruno Haible following an idea of Robert Harley */
     514             : long
     515  2285173344 : vals(ulong z)
     516             : {
     517             :   static char tab[64]={-1,0,1,12,2,6,-1,13,3,-1,7,-1,-1,-1,-1,14,10,4,-1,-1,8,-1,-1,25,-1,-1,-1,-1,-1,21,27,15,31,11,5,-1,-1,-1,-1,-1,9,-1,-1,24,-1,-1,20,26,30,-1,-1,-1,-1,23,-1,19,29,-1,22,18,28,17,16,-1};
     518             : #ifdef LONG_IS_64BIT
     519             :   long s;
     520             : #endif
     521             : 
     522  2285173344 :   if (!z) return -1;
     523             : #ifdef LONG_IS_64BIT
     524  2039489015 :   if (! (z&0xffffffff)) { s = 32; z >>=32; } else s = 0;
     525             : #endif
     526  2285173344 :   z |= ~z + 1;
     527  2285173344 :   z += z << 4;
     528  2285173344 :   z += z << 6;
     529  2285173344 :   z ^= z << 16; /* or  z -= z<<16 */
     530             : #ifdef LONG_IS_64BIT
     531  2039489015 :   return s + tab[(z&0xffffffff)>>26];
     532             : #else
     533   245684329 :   return tab[z>>26];
     534             : #endif
     535             : }
     536             : 
     537             : GEN
     538          21 : divsi(long x, GEN y)
     539             : {
     540          21 :   long p1, s = signe(y);
     541             :   LOCAL_HIREMAINDER;
     542             : 
     543          21 :   if (!s) pari_err_INV("divsi",gen_0);
     544          21 :   if (!x || lgefint(y)>3 || ((long)y[2])<0) return gen_0;
     545          21 :   hiremainder=0; p1=divll(labs(x),y[2]);
     546          21 :   if (x<0) { hiremainder = -((long)hiremainder); p1 = -p1; }
     547          21 :   if (s<0) p1 = -p1;
     548          21 :   return stoi(p1);
     549             : }
     550             : 
     551             : GEN
     552     2509719 : divir(GEN x, GEN y)
     553             : {
     554             :   GEN z;
     555     2509719 :   long ly = lg(y), lx = lgefint(x);
     556             :   pari_sp av;
     557             : 
     558     2509719 :   if (ly == 2) pari_err_INV("divir",y);
     559     2509719 :   if (lx == 2) return div0r(y);
     560     2419125 :   if (lx == 3) {
     561     1255500 :     z = divur(x[2], y);
     562     1255500 :     if (signe(x) < 0) togglesign(z);
     563     1255500 :     return z;
     564             :   }
     565     1163625 :   z = cgetr(ly); av = avma;
     566     1163625 :   affrr(divrr(itor(x, ly+1), y), z);
     567     1163625 :   avma = av; return z;
     568             : }
     569             : 
     570             : GEN
     571     1269843 : divur(ulong x, GEN y)
     572             : {
     573             :   pari_sp av;
     574     1269843 :   long ly = lg(y);
     575             :   GEN z;
     576             : 
     577     1269843 :   if (ly == 2) pari_err_INV("divur",y);
     578     1269843 :   if (!x) return div0r(y);
     579     1269843 :   if (ly > INVNEWTON_LIMIT) {
     580         571 :     av = avma; z = invr(y);
     581         571 :     if (x == 1) return z;
     582         571 :     return gerepileuptoleaf(av, mulur(x, z));
     583             :   }
     584     1269272 :   z = cgetr(ly); av = avma;
     585     1269272 :   affrr(divrr(utor(x,ly+1), y), z);
     586     1269272 :   avma = av; return z;
     587             : }
     588             : 
     589             : GEN
     590        7726 : divsr(long x, GEN y)
     591             : {
     592             :   pari_sp av;
     593        7726 :   long ly = lg(y);
     594             :   GEN z;
     595             : 
     596        7726 :   if (ly == 2) pari_err_INV("divsr",y);
     597        7726 :   if (!x) return div0r(y);
     598        7726 :   if (ly > INVNEWTON_LIMIT) {
     599           0 :     av = avma; z = invr(y);
     600           0 :     if (x == 1) return z;
     601           0 :     if (x ==-1) { togglesign(z); return z; }
     602           0 :     return gerepileuptoleaf(av, mulsr(x, z));
     603             :   }
     604        7726 :   z = cgetr(ly); av = avma;
     605        7726 :   affrr(divrr(stor(x,ly+1), y), z);
     606        7726 :   avma = av; return z;
     607             : }
     608             : 
     609             : /* returns 1/y, assume y != 0 */
     610             : static GEN
     611    11065464 : invr_basecase(GEN y)
     612             : {
     613    11065464 :   long ly = lg(y);
     614    11065464 :   GEN z = cgetr(ly);
     615    11065464 :   pari_sp av = avma;
     616    11065464 :   affrr(divrr(real_1(ly+1), y), z);
     617    11065464 :   avma = av; return z;
     618             : }
     619             : /* returns 1/b, Newton iteration */
     620             : GEN
     621    11065464 : invr(GEN b)
     622             : {
     623    11065464 :   const long s = 6;
     624    11065464 :   long i, p, l = lg(b);
     625             :   GEN x, a;
     626             :   ulong mask;
     627             : 
     628    11065464 :   if (l <= maxss(INVNEWTON_LIMIT, (1L<<s) + 2)) {
     629    11062215 :     if (l == 2) pari_err_INV("invr",b);
     630    11062215 :     return invr_basecase(b);
     631             :   }
     632        3249 :   mask = quadratic_prec_mask(l-2);
     633        3249 :   for(i=0, p=1; i<s; i++) { p <<= 1; if (mask & 1) p--; mask >>= 1; }
     634        3249 :   x = cgetr(l);
     635        3249 :   a = rcopy(b); a[1] = _evalexpo(0) | evalsigne(1);
     636        3249 :   affrr(invr_basecase(rtor(a, p+2)), x);
     637       11503 :   while (mask > 1)
     638             :   {
     639        5005 :     p <<= 1; if (mask & 1) p--;
     640        5005 :     mask >>= 1;
     641        5005 :     setlg(a, p + 2);
     642        5005 :     setlg(x, p + 2);
     643             :     /* TODO: mulrr(a,x) should be a half product (the higher half is known).
     644             :      * mulrr(x, ) already is */
     645        5005 :     affrr(addrr(x, mulrr(x, subsr(1, mulrr(a,x)))), x);
     646        5005 :     avma = (pari_sp)a;
     647             :   }
     648        3249 :   x[1] = (b[1] & SIGNBITS) | evalexpo(expo(x)-expo(b));
     649        3249 :   avma = (pari_sp)x; return x;
     650             : }
     651             : 
     652             : GEN
     653  1371089756 : modii(GEN x, GEN y)
     654             : {
     655  1371089756 :   switch(signe(x))
     656             :   {
     657   339033460 :     case 0: return gen_0;
     658   707934152 :     case 1: return remii(x,y);
     659             :     default:
     660             :     {
     661   324122144 :       pari_sp av = avma;
     662   324122144 :       (void)new_chunk(lgefint(y));
     663   324116141 :       x = remii(x,y); avma=av;
     664   324120322 :       if (x==gen_0) return x;
     665   302029983 :       return subiispec(y+2,x+2,lgefint(y)-2,lgefint(x)-2);
     666             :     }
     667             :   }
     668             : }
     669             : 
     670             : void
     671      516176 : modiiz(GEN x, GEN y, GEN z)
     672             : {
     673      516176 :   const pari_sp av = avma;
     674      516176 :   affii(modii(x,y),z); avma=av;
     675      516176 : }
     676             : 
     677             : GEN
     678     3474379 : divrs(GEN x, long y)
     679             : {
     680             :   GEN z;
     681     3474379 :   if (y < 0)
     682             :   {
     683      352983 :     z = divru(x, (ulong)-y);
     684      352983 :     togglesign(z);
     685             :   }
     686             :   else
     687     3121396 :     z = divru(x, (ulong)y);
     688     3474379 :   return z;
     689             : }
     690             : 
     691             : GEN
     692   492105404 : divru(GEN x, ulong y)
     693             : {
     694   492105404 :   long i, lx, sh, e, s = signe(x);
     695             :   ulong garde;
     696             :   GEN z;
     697             :   LOCAL_HIREMAINDER;
     698             : 
     699   492105404 :   if (!y) pari_err_INV("divru",gen_0);
     700   492105404 :   if (!s) return real_0_bit(expo(x) - expu(y));
     701   492046633 :   if (!(y & (y-1))) /* power of 2 */
     702             :   {
     703    34368375 :     if (y == 1) return rcopy(x);
     704    32583197 :     return shiftr(x, -expu(y));
     705             :   }
     706   457678258 :   e = expo(x);
     707   457678258 :   lx = lg(x);
     708   457678258 :   z = cgetr(lx);
     709   457678258 :   if (lx == 3)
     710             :   {
     711   277829820 :     if (y <= uel(x,2))
     712             :     {
     713   277829664 :       hiremainder = 0;
     714   277829664 :       z[2] = divll(x[2],y);
     715             :       /* we may have hiremainder != 0 ==> garde */
     716   277829664 :       garde = divll(0,y);
     717             :     }
     718             :     else
     719             :     {
     720         156 :       hiremainder = x[2];
     721         156 :       z[2] = divll(0,y);
     722         156 :       garde = hiremainder;
     723         156 :       e -= BITS_IN_LONG;
     724             :     }
     725             :   }
     726             :   else
     727             :   {
     728   179848438 :     ulong yp = get_Fl_red(y);
     729   179848438 :     if (y <= uel(x,2))
     730             :     {
     731   179845981 :       hiremainder = 0;
     732   179845981 :       for (i=2; i<lx; i++) z[i] = divll_pre(x[i],y,yp);
     733             :       /* we may have hiremainder != 0 ==> garde */
     734   179845981 :       garde = divll_pre(0,y,yp);
     735             :     }
     736             :     else
     737             :     {
     738        2457 :       long l = lx-1;
     739        2457 :       hiremainder = x[2];
     740        2457 :       for (i=2; i<l; i++) z[i] = divll_pre(x[i+1],y,yp);
     741        2457 :       z[i] = divll_pre(0,y,yp);
     742        2457 :       garde = hiremainder;
     743        2457 :       e -= BITS_IN_LONG;
     744             :     }
     745             :   }
     746   457678258 :   sh=bfffo(z[2]); /* z[2] != 0 */
     747   457678258 :   if (sh) shift_left(z,z, 2,lx-1, garde,sh);
     748   457678258 :   z[1] = evalsigne(s) | evalexpo(e-sh);
     749   457678258 :   if ((garde << sh) & HIGHBIT) roundr_up_ip(z, lx);
     750   457678258 :   return z;
     751             : }
     752             : 
     753             : GEN
     754    51287767 : truedvmdii(GEN x, GEN y, GEN *z)
     755             : {
     756             :   pari_sp av;
     757             :   GEN r, q, *gptr[2];
     758    51287767 :   if (!is_bigint(y)) return truedvmdis(x, itos(y), z);
     759      716438 :   if (z == ONLY_REM) return modii(x,y);
     760             : 
     761      716438 :   av = avma;
     762      716438 :   q = dvmdii(x,y,&r); /* assume that r is last on stack */
     763      716438 :   switch(signe(r))
     764             :   {
     765             :     case 0:
     766       57868 :       if (z) *z = gen_0;
     767       57868 :       return q;
     768             :     case 1:
     769      535334 :       if (z) *z = r; else cgiv(r);
     770      535334 :       return q;
     771      123236 :     case -1: break;
     772             :   }
     773      123236 :   q = addis(q, -signe(y));
     774      123236 :   if (!z) return gerepileuptoint(av, q);
     775             : 
     776       19556 :   *z = subiispec(y+2,r+2, lgefint(y)-2,lgefint(r)-2);
     777       19556 :   gptr[0]=&q; gptr[1]=z; gerepilemanysp(av,(pari_sp)r,gptr,2);
     778       19556 :   return q;
     779             : }
     780             : GEN
     781    50692536 : truedvmdis(GEN x, long y, GEN *z)
     782             : {
     783    50692536 :   pari_sp av = avma;
     784             :   long r;
     785             :   GEN q;
     786             : 
     787    50692536 :   if (z == ONLY_REM) return modis(x, y);
     788    50692536 :   q = divis_rem(x,y,&r);
     789             : 
     790    50692536 :   if (r >= 0)
     791             :   {
     792    45294045 :     if (z) *z = utoi(r);
     793    45294045 :     return q;
     794             :   }
     795     5398491 :   q = gerepileuptoint(av, addis(q, (y < 0)? 1: -1));
     796     5398491 :   if (z) *z = utoi(r + labs(y));
     797     5398491 :   return q;
     798             : }
     799             : GEN
     800     6083888 : truedvmdsi(long x, GEN y, GEN *z)
     801             : {
     802             :   long q, r;
     803     6083888 :   if (z == ONLY_REM) return modsi(x, y);
     804     6083888 :   q = sdivsi_rem(x,y,&r);
     805     6083888 :   if (r >= 0) {
     806     6083881 :     if (z) *z = utoi(r);
     807     6083881 :     return stoi(q);
     808             :   }
     809           7 :   q = q - signe(y);
     810           7 :   if (!z) return stoi(q);
     811             : 
     812           0 :   *z = subiuspec(y+2,(ulong)-r, lgefint(y)-2);
     813           0 :   return stoi(q);
     814             : }
     815             : 
     816             : /* 2^n = shifti(gen_1, n) */
     817             : GEN
     818    72696010 : int2n(long n) {
     819             :   long i, m, l;
     820             :   GEN z;
     821    72696010 :   if (n < 0) return gen_0;
     822    72694938 :   if (n == 0) return gen_1;
     823             : 
     824    72050558 :   l = dvmdsBIL(n, &m) + 3;
     825    72050546 :   z = cgetipos(l);
     826    72050575 :   for (i = 2; i < l; i++) z[i] = 0;
     827    72050575 :   *int_MSW(z) = 1UL << m; return z;
     828             : }
     829             : /* To avoid problems when 2^(BIL-1) < n. Overflow cleanly, where int2n
     830             :  * returns gen_0 */
     831             : GEN
     832     6053579 : int2u(ulong n) {
     833             :   ulong i, m, l;
     834             :   GEN z;
     835     6053579 :   if (n == 0) return gen_1;
     836             : 
     837     6053579 :   l = dvmduBIL(n, &m) + 3;
     838     6053579 :   z = cgetipos(l);
     839     6053560 :   for (i = 2; i < l; i++) z[i] = 0;
     840     6053560 :   *int_MSW(z) = 1UL << m; return z;
     841             : }
     842             : 
     843             : GEN
     844   808471442 : shifti(GEN x, long n)
     845             : {
     846   808471442 :   long s = signe(x);
     847             :   GEN y;
     848             : 
     849   808471442 :   if(s == 0) return gen_0;
     850   739916909 :   y = shiftispec(x + 2, lgefint(x) - 2, n);
     851   739860251 :   if (signe(y)) setsigne(y, s);
     852   739860251 :   return y;
     853             : }
     854             : 
     855             : /* actual operations will take place on a+2 and b+2: we strip the codewords */
     856             : GEN
     857  7448347857 : mulii(GEN a,GEN b)
     858             : {
     859             :   long sa,sb;
     860             :   GEN z;
     861             : 
     862  7448347857 :   sa=signe(a); if (!sa) return gen_0;
     863  4918247882 :   sb=signe(b); if (!sb) return gen_0;
     864  3267729707 :   if (sb<0) sa = -sa;
     865  3267729707 :   z = muliispec(a+2,b+2, lgefint(a)-2,lgefint(b)-2);
     866  3268643638 :   setsigne(z,sa); return z;
     867             : }
     868             : 
     869             : GEN
     870  1111051821 : sqri(GEN a) { return sqrispec(a+2, lgefint(a)-2); }
     871             : 
     872             : /* sqrt()'s result may be off by 1 when a is not representable exactly as a
     873             :  * double [64bit machine] */
     874             : ulong
     875     4068765 : usqrt(ulong a)
     876             : {
     877     4068765 :   ulong x = (ulong)sqrt((double)a);
     878             : #ifdef LONG_IS_64BIT
     879     2909322 :   if (x > LOWMASK || x*x > a) x--;
     880             : #endif
     881     4068765 :   return x;
     882             : }
     883             : 
     884             : /********************************************************************/
     885             : /**                                                                **/
     886             : /**              EXPONENT / CONVERSION t_REAL --> double           **/
     887             : /**                                                                **/
     888             : /********************************************************************/
     889             : 
     890             : #ifdef LONG_IS_64BIT
     891             : long
     892           0 : dblexpo(double x)
     893             : {
     894             :   union { double f; ulong i; } fi;
     895           0 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
     896           0 :   const int exp_mid = 0x3ff;/* exponent bias */
     897             : 
     898           0 :   if (x==0.) return -exp_mid;
     899           0 :   fi.f = x;
     900           0 :   return ((fi.i & (HIGHBIT-1)) >> mant_len) - exp_mid;
     901             : }
     902             : 
     903             : ulong
     904           0 : dblmantissa(double x)
     905             : {
     906             :   union { double f; ulong i; } fi;
     907           0 :   const int expo_len = 11; /* number of bits of exponent */
     908             : 
     909           0 :   if (x==0.) return 0;
     910           0 :   fi.f = x;
     911           0 :   return (fi.i << expo_len) | HIGHBIT;
     912             : }
     913             : 
     914             : GEN
     915     5661130 : dbltor(double x)
     916             : {
     917             :   GEN z;
     918             :   long e;
     919             :   union { double f; ulong i; } fi;
     920     5661130 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
     921     5661130 :   const int exp_mid = 0x3ff;/* exponent bias */
     922     5661130 :   const int expo_len = 11; /* number of bits of exponent */
     923             : 
     924     5661130 :   if (x==0.) return real_0_bit(-exp_mid);
     925     5660832 :   fi.f = x; z = cgetr(DEFAULTPREC);
     926             :   {
     927     5660832 :     const ulong a = fi.i;
     928             :     ulong A;
     929     5660832 :     e = ((a & (HIGHBIT-1)) >> mant_len) - exp_mid;
     930     5660832 :     if (e == exp_mid+1) pari_err_OVERFLOW("dbltor [NaN or Infinity]");
     931     5660832 :     A = a << expo_len;
     932     5660832 :     if (e == -exp_mid)
     933             :     { /* unnormalized values */
     934           0 :       int sh = bfffo(A);
     935           0 :       e -= sh-1;
     936           0 :       z[2] = A << sh;
     937             :     }
     938             :     else
     939     5660832 :       z[2] = HIGHBIT | A;
     940     5660832 :     z[1] = _evalexpo(e) | evalsigne(x<0? -1: 1);
     941             :   }
     942     5660832 :   return z;
     943             : }
     944             : 
     945             : double
     946    24559419 : rtodbl(GEN x)
     947             : {
     948    24559419 :   long ex,s=signe(x);
     949             :   ulong a;
     950             :   union { double f; ulong i; } fi;
     951    24559419 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
     952    24559419 :   const int exp_mid = 0x3ff;/* exponent bias */
     953    24559419 :   const int expo_len = 11; /* number of bits of exponent */
     954             : 
     955    24559419 :   if (!s || (ex=expo(x)) < - exp_mid) return 0.0;
     956             : 
     957             :   /* start by rounding to closest */
     958    24096586 :   a = (x[2] & (HIGHBIT-1)) + 0x400;
     959    24096586 :   if (a & HIGHBIT) { ex++; a=0; }
     960    24096586 :   if (ex >= exp_mid) pari_err_OVERFLOW("t_REAL->double conversion");
     961    24096586 :   fi.i = ((ex + exp_mid) << mant_len) | (a >> expo_len);
     962    24096586 :   if (s<0) fi.i |= HIGHBIT;
     963    24096586 :   return fi.f;
     964             : }
     965             : 
     966             : #else /* LONG_IS_64BIT */
     967             : 
     968             : #if   PARI_DOUBLE_FORMAT == 1
     969             : #  define INDEX0 1
     970             : #  define INDEX1 0
     971             : #elif PARI_DOUBLE_FORMAT == 0
     972             : #  define INDEX0 0
     973             : #  define INDEX1 1
     974             : #endif
     975             : 
     976             : long
     977           0 : dblexpo(double x)
     978             : {
     979             :   union { double f; ulong i[2]; } fi;
     980           0 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
     981           0 :   const int exp_mid = 0x3ff;/* exponent bias */
     982           0 :   const int shift = mant_len-32;
     983             : 
     984           0 :   if (x==0.) return -exp_mid;
     985           0 :   fi.f = x;
     986             :   {
     987           0 :     const ulong a = fi.i[INDEX0];
     988           0 :     return ((a & (HIGHBIT-1)) >> shift) - exp_mid;
     989             :   }
     990             : }
     991             : 
     992             : ulong
     993           0 : dblmantissa(double x)
     994             : {
     995             :   union { double f; ulong i[2]; } fi;
     996           0 :   const int expo_len = 11; /* number of bits of exponent */
     997             : 
     998           0 :   if (x==0.) return 0;
     999           0 :   fi.f = x;
    1000             :   {
    1001           0 :     const ulong a = fi.i[INDEX0];
    1002           0 :     const ulong b = fi.i[INDEX1];
    1003           0 :     return HIGHBIT | b >> (BITS_IN_LONG-expo_len) | (a << expo_len);
    1004             :   }
    1005             : }
    1006             : 
    1007             : GEN
    1008      953375 : dbltor(double x)
    1009             : {
    1010             :   GEN z;
    1011             :   long e;
    1012             :   union { double f; ulong i[2]; } fi;
    1013      953375 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
    1014      953375 :   const int exp_mid = 0x3ff;/* exponent bias */
    1015      953375 :   const int expo_len = 11; /* number of bits of exponent */
    1016      953375 :   const int shift = mant_len-32;
    1017             : 
    1018      953375 :   if (x==0.) return real_0_bit(-exp_mid);
    1019      953328 :   fi.f = x; z = cgetr(DEFAULTPREC);
    1020             :   {
    1021      953328 :     const ulong a = fi.i[INDEX0];
    1022      953328 :     const ulong b = fi.i[INDEX1];
    1023             :     ulong A, B;
    1024      953328 :     e = ((a & (HIGHBIT-1)) >> shift) - exp_mid;
    1025      953328 :     if (e == exp_mid+1) pari_err_OVERFLOW("dbltor [NaN or Infinity]");
    1026      953328 :     A = b >> (BITS_IN_LONG-expo_len) | (a << expo_len);
    1027      953328 :     B = b << expo_len;
    1028      953328 :     if (e == -exp_mid)
    1029             :     { /* unnormalized values */
    1030             :       int sh;
    1031           0 :       if (A)
    1032             :       {
    1033           0 :         sh = bfffo(A);
    1034           0 :         e -= sh-1;
    1035           0 :         z[2] = (A << sh) | (B >> (32-sh));
    1036           0 :         z[3] = B << sh;
    1037             :       }
    1038             :       else
    1039             :       {
    1040           0 :         sh = bfffo(B); /* B != 0 */
    1041           0 :         e -= sh-1 + 32;
    1042           0 :         z[2] = B << sh;
    1043           0 :         z[3] = 0;
    1044             :       }
    1045             :     }
    1046             :     else
    1047             :     {
    1048      953328 :       z[3] = B;
    1049      953328 :       z[2] = HIGHBIT | A;
    1050             :     }
    1051      953328 :     z[1] = _evalexpo(e) | evalsigne(x<0? -1: 1);
    1052             :   }
    1053      953328 :   return z;
    1054             : }
    1055             : 
    1056             : double
    1057     3975717 : rtodbl(GEN x)
    1058             : {
    1059     3975717 :   long ex,s=signe(x),lx=lg(x);
    1060             :   ulong a,b,k;
    1061             :   union { double f; ulong i[2]; } fi;
    1062     3975717 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
    1063     3975717 :   const int exp_mid = 0x3ff;/* exponent bias */
    1064     3975717 :   const int expo_len = 11; /* number of bits of exponent */
    1065     3975717 :   const int shift = mant_len-32;
    1066             : 
    1067     3975717 :   if (!s || (ex=expo(x)) < - exp_mid) return 0.0;
    1068             : 
    1069             :   /* start by rounding to closest */
    1070     3899456 :   a = x[2] & (HIGHBIT-1);
    1071     3899456 :   if (lx > 3)
    1072             :   {
    1073     3737271 :     b = x[3] + 0x400UL; if (b < 0x400UL) a++;
    1074     3737271 :     if (a & HIGHBIT) { ex++; a=0; }
    1075             :   }
    1076      162185 :   else b = 0;
    1077     3899456 :   if (ex >= exp_mid) pari_err_OVERFLOW("t_REAL->double conversion");
    1078     3899456 :   ex += exp_mid;
    1079     3899456 :   k = (a >> expo_len) | (ex << shift);
    1080     3899456 :   if (s<0) k |= HIGHBIT;
    1081     3899456 :   fi.i[INDEX0] = k;
    1082     3899456 :   fi.i[INDEX1] = (a << (BITS_IN_LONG-expo_len)) | (b >> expo_len);
    1083     3899456 :   return fi.f;
    1084             : }
    1085             : #endif /* LONG_IS_64BIT */
    1086             : 

Generated by: LCOV version 1.11