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 19230-c71492b) Lines: 513 558 91.9 %
Date: 2016-07-30 07:10:28 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    23307306 : invmod2BIL(ulong b)
      18             : {
      19             :   static int tab[] = { 0, 0, 0, 8, 0, 8, 0, 0 };
      20    23307306 :   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    23307306 :   x = x*(2-b*x); /* one more pass necessary */
      25             : #endif
      26    23307306 :   x = x*(2-b*x);
      27    23307306 :   x = x*(2-b*x); return x*(2-b*x);
      28             : }
      29             : 
      30             : void
      31  1232355133 : affrr(GEN x, GEN y)
      32             : {
      33             :   long lx,ly,i;
      34             : 
      35  1232355133 :   y[1] = x[1]; if (!signe(x)) return;
      36             : 
      37  1225141879 :   lx=lg(x); ly=lg(y);
      38  1225141879 :   if (lx <= ly)
      39             :   {
      40  1168024492 :     for (i=2; i<lx; i++) y[i]=x[i];
      41  1168024492 :     for (   ; i<ly; i++) y[i]=0;
      42  1168024492 :     return;
      43             :   }
      44    57117387 :   for (i=2; i<ly; i++) y[i]=x[i];
      45             :   /* lx > ly: round properly */
      46    57117387 :   if (x[ly] & HIGHBIT) roundr_up_ip(y, ly);
      47             : }
      48             : 
      49             : GEN
      50     5964563 : trunc2nr(GEN x, long n)
      51             : {
      52             :   long ex;
      53     5964563 :   if (!signe(x)) return gen_0;
      54     5930540 :   ex = expo(x) + n; if (ex < 0) return gen_0;
      55     5656330 :   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    16900080 : mantissa_real(GEN x, long *e)
      61             : {
      62    16900080 :   *e = bit_prec(x)-1-expo(x);
      63    16900080 :   return mantissa2nr(x, 0);
      64             : }
      65             : 
      66             : GEN
      67  1058242861 : mului(ulong x, GEN y)
      68             : {
      69  1058242861 :   long s = signe(y);
      70             :   GEN z;
      71             : 
      72  1058242861 :   if (!s || !x) return gen_0;
      73  1006075320 :   z = muluispec(x, y+2, lgefint(y)-2);
      74  1001995908 :   setsigne(z,s); return z;
      75             : }
      76             : 
      77             : GEN
      78   129060508 : mulsi(long x, GEN y)
      79             : {
      80   129060508 :   long s = signe(y);
      81             :   GEN z;
      82             : 
      83   129060508 :   if (!s || !x) return gen_0;
      84    94069781 :   if (x<0) { s = -s; x = -x; }
      85    94069781 :   z = muluispec((ulong)x, y+2, lgefint(y)-2);
      86    94069773 :   setsigne(z,s); return z;
      87             : }
      88             : 
      89             : GEN
      90    29965476 : mulss(long x, long y)
      91             : {
      92             :   long p1;
      93             :   LOCAL_HIREMAINDER;
      94             : 
      95    29965476 :   if (!x || !y) return gen_0;
      96    29868876 :   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    29809250 :     if (y<0) { y = -y; p1 = mulll(x,y); return uutoineg(hiremainder, p1); }
     102    29808759 :     p1 = mulll(x,y); return uutoi(hiremainder, p1);
     103             :   }
     104             : }
     105             : GEN
     106        4187 : sqrs(long x)
     107             : {
     108             :   long p1;
     109             :   LOCAL_HIREMAINDER;
     110             : 
     111        4187 :   if (!x) return gen_0;
     112        4187 :   if (x<0) x = -x;
     113        4187 :   p1 = mulll(x,x); return uutoi(hiremainder, p1);
     114             : }
     115             : GEN
     116  1651227339 : muluu(ulong x, ulong y)
     117             : {
     118             :   long p1;
     119             :   LOCAL_HIREMAINDER;
     120             : 
     121  1651227339 :   if (!x || !y) return gen_0;
     122  1651185465 :   p1 = mulll(x,y); return uutoi(hiremainder, p1);
     123             : }
     124             : GEN
     125   584600271 : sqru(ulong x)
     126             : {
     127             :   long p1;
     128             :   LOCAL_HIREMAINDER;
     129             : 
     130   584600271 :   if (!x) return gen_0;
     131   584563536 :   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   449060958 : mulur_2(ulong x, GEN y, long s)
     137             : {
     138   449060958 :   long m, sh, i, lx = lg(y), e = expo(y);
     139   449060958 :   GEN z = cgetr(lx);
     140             :   ulong garde;
     141             :   LOCAL_HIREMAINDER;
     142             : 
     143   449060958 :   y--; garde = mulll(x,y[lx]);
     144   449060958 :   for (i=lx-1; i>=3; i--) z[i]=addmul(x,y[i]);
     145   449060958 :   z[2]=hiremainder; /* != 0 since y normalized and |x| > 1 */
     146   449060958 :   sh = bfffo(hiremainder); m = BITS_IN_LONG-sh;
     147   449060958 :   if (sh) shift_left(z,z, 2,lx-1, garde,sh);
     148   449060958 :   z[1] = evalsigne(s) | evalexpo(m+e);
     149   449060958 :   if ((garde << sh) & HIGHBIT) roundr_up_ip(z, lx);
     150   449060958 :   return z;
     151             : }
     152             : 
     153             : INLINE GEN
     154     1145748 : mul0r(GEN x)
     155             : {
     156     1145748 :   long l = lg(x), e = expo(x);
     157     1145748 :   e = (l > 2)? -prec2nbits(l) + e: (e < 0? 2*e: 0);
     158     1145748 :   return real_0_bit(e);
     159             : }
     160             : /* lg(x) > 2 */
     161             : INLINE GEN
     162       90272 : div0r(GEN x) {
     163       90272 :   long l = lg(x), e = expo(x);
     164       90272 :   return real_0_bit(-prec2nbits(l) - e);
     165             : }
     166             : 
     167             : GEN
     168    37037265 : mulsr(long x, GEN y)
     169             : {
     170             :   long s;
     171             : 
     172    37037265 :   if (!x) return mul0r(y);
     173    36019885 :   s = signe(y);
     174    36019885 :   if (!s)
     175             :   {
     176       52301 :     if (x < 0) x = -x;
     177       52301 :     return real_0_bit( expo(y) + expu(x) );
     178             :   }
     179    35967584 :   if (x==1)  return rcopy(y);
     180    35513132 :   if (x==-1) return negr(y);
     181    34548708 :   if (x < 0)
     182    21448252 :     return mulur_2((ulong)-x, y, -s);
     183             :   else
     184    13100456 :     return mulur_2((ulong)x, y, s);
     185             : }
     186             : 
     187             : GEN
     188   457528413 : mulur(ulong x, GEN y)
     189             : {
     190             :   long s;
     191             : 
     192   457528413 :   if (!x) return mul0r(y);
     193   457528413 :   s = signe(y);
     194   457528413 :   if (!s) return real_0_bit( expo(y) + expu(x) );
     195   455871121 :   if (x==1) return rcopy(y);
     196   414512250 :   return mulur_2(x, y, s);
     197             : }
     198             : 
     199             : INLINE void
     200   990769291 : mulrrz_end(GEN z, GEN hi, long lz, long sz, long ez, ulong garde)
     201             : {
     202             :   long i;
     203   990769291 :   if (hi[2] < 0)
     204             :   {
     205   448876464 :     if (z != hi)
     206    29648236 :       for (i=2; i<lz ; i++) z[i] = hi[i];
     207   448876464 :     ez++;
     208             :   }
     209             :   else
     210             :   {
     211   541892827 :     shift_left(z,hi,2,lz-1, garde, 1);
     212   541892827 :     garde <<= 1;
     213             :   }
     214   990769291 :   if (garde & HIGHBIT)
     215             :   { /* round to nearest */
     216   485058358 :     i = lz; do ((ulong*)z)[--i]++; while (i>1 && z[i]==0);
     217   485058358 :     if (i == 1) { z[2] = (long)HIGHBIT; ez++; }
     218             :   }
     219   990769291 :   z[1] = evalsigne(sz)|evalexpo(ez);
     220   990769291 : }
     221             : /* mulrrz_end for lz = 3, minor simplifications. z[2]=hiremainder from mulll */
     222             : INLINE void
     223  1350562408 : mulrrz_3end(GEN z, long sz, long ez, ulong garde)
     224             : {
     225  1350562408 :   if (z[2] < 0)
     226             :   { /* z2 < (2^BIL-1)^2 / 2^BIL, hence z2+1 != 0 */
     227   745546894 :     if (garde & HIGHBIT) z[2]++; /* round properly */
     228   745546894 :     ez++;
     229             :   }
     230             :   else
     231             :   {
     232   605015514 :     uel(z,2) = (uel(z,2)<<1) | (garde>>(BITS_IN_LONG-1));
     233   605015514 :     if (garde & (1UL<<(BITS_IN_LONG-2)))
     234             :     {
     235   289564139 :       uel(z,2)++; /* round properly, z2+1 can overflow */
     236   289564139 :       if (!uel(z,2)) { uel(z,2) = HIGHBIT; ez++; }
     237             :     }
     238             :   }
     239  1350562408 :   z[1] = evalsigne(sz)|evalexpo(ez);
     240  1350562408 : }
     241             : 
     242             : /* set z <-- x^2 != 0, floating point multiplication.
     243             :  * lz = lg(z) = lg(x) */
     244             : INLINE void
     245    69159482 : sqrz_i(GEN z, GEN x, long lz)
     246             : {
     247    69159482 :   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    69159482 :   if (lz > MULRR_MULII_LIMIT)
     255             :   {
     256     4220816 :     pari_sp av = avma;
     257     4220816 :     GEN hi = sqrispec_mirror(x+2, lz-2);
     258     4220816 :     mulrrz_end(z, hi, lz, 1, ez, hi[lz]);
     259     4220816 :     avma = av; return;
     260             :   }
     261    64938666 :   if (lz == 3)
     262             :   {
     263    10927725 :     garde = mulll(x[2],x[2]);
     264    10927725 :     z[2] = hiremainder;
     265    10927725 :     mulrrz_3end(z, 1, ez, garde);
     266    10927725 :     return;
     267             :   }
     268             : 
     269    54010941 :   lzz = lz-1; p1 = x[lzz];
     270    54010941 :   if (p1)
     271             :   {
     272    47725748 :     (void)mulll(p1,x[3]);
     273    47725748 :     garde = addmul(p1,x[2]);
     274    47725748 :     z[lzz] = hiremainder;
     275             :   }
     276             :   else
     277             :   {
     278     6285193 :     garde = 0;
     279     6285193 :     z[lzz] = 0;
     280             :   }
     281   173284786 :   for (j=lz-2, x1=x-j; j>=3; j--)
     282             :   {
     283   119273845 :     p1 = x[j]; x1++;
     284   119273845 :     if (p1)
     285             :     {
     286   115826925 :       (void)mulll(p1,x1[lz+1]);
     287   115826925 :       garde = addll(addmul(p1,x1[lz]), garde);
     288   483450192 :       for (i=lzz; i>j; i--)
     289             :       {
     290   367623267 :         hiremainder += overflow;
     291   367623267 :         z[i] = addll(addmul(p1,x1[i]), z[i]);
     292             :       }
     293   115826925 :       z[j] = hiremainder+overflow;
     294             :     }
     295     3446920 :     else z[j]=0;
     296             :   }
     297    54010941 :   p1 = x[2]; x1++;
     298    54010941 :   garde = addll(mulll(p1,x1[lz]), garde);
     299   227295727 :   for (i=lzz; i>2; i--)
     300             :   {
     301   173284786 :     hiremainder += overflow;
     302   173284786 :     z[i] = addll(addmul(p1,x1[i]), z[i]);
     303             :   }
     304    54010941 :   z[2] = hiremainder+overflow;
     305    54010941 :   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    60373193 : mulrrz_int(GEN z, GEN x, GEN y, long lz, long flag, long sz)
     311             : {
     312    60373193 :   pari_sp av = avma;
     313    60373193 :   GEN hi = muliispec_mirror(y+2, x+2, lz+flag-2, lz-2);
     314    60373193 :   mulrrz_end(z, hi, lz, sz, expo(x)+expo(y), hi[lz]);
     315    60373193 :   avma = av;
     316    60373193 : }
     317             : 
     318             : /* lz = 3 */
     319             : INLINE void
     320  1339634683 : mulrrz_3(GEN z, GEN x, GEN y, long flag, long sz)
     321             : {
     322             :   ulong garde;
     323             :   LOCAL_HIREMAINDER;
     324  1339634683 :   if (flag)
     325             :   {
     326    14109764 :     (void)mulll(x[2],y[3]);
     327    14109764 :     garde = addmul(x[2],y[2]);
     328             :   }
     329             :   else
     330  1325524919 :     garde = mulll(x[2],y[2]);
     331  1339634683 :   z[2] = hiremainder;
     332  1339634683 :   mulrrz_3end(z, sz, expo(x)+expo(y), garde);
     333  1339634683 : }
     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  2271335600 : 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  2271335600 :   if (x == y) { sqrz_i(z,x,lz); return; }
     348  2271335600 :   if (lz > MULRR_MULII_LIMIT) { mulrrz_int(z,x,y,lz,flag,sz); return; }
     349  2210962407 :   if (lz == 3) { mulrrz_3(z,x,y,flag,sz); return; }
     350   871327724 :   ez = expo(x) + expo(y);
     351   871327724 :   if (flag) { (void)mulll(x[2],y[lz]); garde = hiremainder; } else garde = 0;
     352   871327724 :   lzz=lz-1; p1=x[lzz];
     353   871327724 :   if (p1)
     354             :   {
     355   838182721 :     (void)mulll(p1,y[3]);
     356   838182721 :     garde = addll(addmul(p1,y[2]), garde);
     357   838182721 :     z[lzz] = overflow+hiremainder;
     358             :   }
     359    33145003 :   else z[lzz]=0;
     360  2716300435 :   for (j=lz-2, y1=y-j; j>=3; j--)
     361             :   {
     362  1844972711 :     p1 = x[j]; y1++;
     363  1844972711 :     if (p1)
     364             :     {
     365  1785871562 :       (void)mulll(p1,y1[lz+1]);
     366  1785871562 :       garde = addll(addmul(p1,y1[lz]), garde);
     367  7142963318 :       for (i=lzz; i>j; i--)
     368             :       {
     369  5357091756 :         hiremainder += overflow;
     370  5357091756 :         z[i] = addll(addmul(p1,y1[i]), z[i]);
     371             :       }
     372  1785871562 :       z[j] = hiremainder+overflow;
     373             :     }
     374    59101149 :     else z[j]=0;
     375             :   }
     376   871327724 :   p1 = x[2]; y1++;
     377   871327724 :   garde = addll(mulll(p1,y1[lz]), garde);
     378  3587628159 :   for (i=lzz; i>2; i--)
     379             :   {
     380  2716300435 :     hiremainder += overflow;
     381  2716300435 :     z[i] = addll(addmul(p1,y1[i]), z[i]);
     382             :   }
     383   871327724 :   z[2] = hiremainder+overflow;
     384   871327724 :   mulrrz_end(z, z, lz, sz, ez, garde);
     385             : }
     386             : 
     387             : GEN
     388  2294894253 : mulrr(GEN x, GEN y)
     389             : {
     390             :   long flag, ly, lz, sx, sy;
     391             :   GEN z;
     392             : 
     393  2294894253 :   if (x == y) return sqrr(x);
     394  2294792168 :   sx = signe(x); if (!sx) return real_0_bit(expo(x) + expo(y));
     395  2266763179 :   sy = signe(y); if (!sy) return real_0_bit(expo(x) + expo(y));
     396  2256877991 :   if (sy < 0) sx = -sx;
     397  2256877991 :   lz = lg(x);
     398  2256877991 :   ly = lg(y);
     399  2256877991 :   if (lz > ly) { lz = ly; swap(x, y); flag = 1; } else flag = (lz != ly);
     400  2256877991 :   z = cgetr(lz);
     401  2256877991 :   mulrrz_i(z, x,y, lz,flag, sx);
     402  2256877991 :   return z;
     403             : }
     404             : 
     405             : GEN
     406    70427754 : sqrr(GEN x)
     407             : {
     408    70427754 :   long lz, sx = signe(x);
     409             :   GEN z;
     410             : 
     411    70427754 :   if (!sx) return real_0_bit(2*expo(x));
     412    69159482 :   lz = lg(x); z = cgetr(lz);
     413    69159482 :   sqrz_i(z, x, lz);
     414    69159482 :   return z;
     415             : }
     416             : 
     417             : GEN
     418   143177164 : mulir(GEN x, GEN y)
     419             : {
     420   143177164 :   long sx = signe(x), sy;
     421   143177164 :   if (!sx) return mul0r(y);
     422   143048796 :   if (lgefint(x) == 3) {
     423   126588722 :     GEN z = mulur(uel(x,2), y);
     424   126588722 :     if (sx < 0) togglesign(z);
     425   126588722 :     return z;
     426             :   }
     427    16460074 :   sy = signe(y);
     428    16460074 :   if (!sy) return real_0_bit(expi(x) + expo(y));
     429    15294226 :   if (sy < 0) sx = -sx;
     430             :   {
     431    15294226 :     long lz = lg(y), lx = lgefint(x);
     432    15294226 :     GEN hi, z = cgetr(lz);
     433    15294226 :     pari_sp av = avma;
     434    15294226 :     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      836617 :       x = itor(x, lx);
     438      836617 :       hi = muliispec_mirror(y+2, x+2, lz-2, lx-2);
     439      836617 :       mulrrz_end(z, hi, lz, sx, expo(x)+expo(y), hi[lz]);
     440             :     }
     441             :     else /* dubious: complete x with 0s and call mulrr */
     442    14457609 :       mulrrz_i(z, itor(x,lz), y, lz, 0, sx);
     443    15294226 :     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    19016662 : addmulii_gen(GEN x, GEN y, GEN z, long lz)
     450             : {
     451    19016662 :   long lx = lgefint(x), ly;
     452             :   pari_sp av;
     453             :   GEN t;
     454    19016662 :   if (lx == 2) return mulii(z,y);
     455    18471835 :   ly = lgefint(y);
     456    18471835 :   if (ly == 2) return icopy(x); /* y = 0, wasteful copy */
     457    18390122 :   av = avma; (void)new_chunk(lx+ly+lz); /*HACK*/
     458    18390122 :   t = mulii(z, y);
     459    18390122 :   avma = av; return addii(t,x);
     460             : }
     461             : /* x + y*z, lgefint(z) == 3 */
     462             : static GEN
     463   218158205 : addmulii_lg3(GEN x, GEN y, GEN z)
     464             : {
     465   218158205 :   long s = signe(z), lx, ly;
     466   218158205 :   ulong w = z[2];
     467             :   pari_sp av;
     468             :   GEN t;
     469   218158205 :   if (w == 1) return (s > 0)? addii(x,y): subii(x,y); /* z = +- 1 */
     470   158723423 :   lx = lgefint(x);
     471   158723423 :   ly = lgefint(y);
     472   158723423 :   if (lx == 2)
     473             :   { /* x = 0 */
     474    27191632 :     if (ly == 2) return gen_0;
     475    22376689 :     t = muluispec(w, y+2, ly-2);
     476    22376689 :     if (signe(y) < 0) s = -s;
     477    22376689 :     setsigne(t, s); return t;
     478             :   }
     479   131531791 :   if (ly == 2) return icopy(x); /* y = 0, wasteful copy */
     480   125924092 :   av = avma; (void)new_chunk(1+lx+ly);/*HACK*/
     481   125924092 :   t = muluispec(w, y+2, ly-2);
     482   125924092 :   if (signe(y) < 0) s = -s;
     483   125924092 :   setsigne(t, s);
     484   125924092 :   avma = av; return addii(x,t);
     485             : }
     486             : /* x + y*z */
     487             : GEN
     488    30067840 : addmulii(GEN x, GEN y, GEN z)
     489             : {
     490    30067840 :   long lz = lgefint(z);
     491    30067840 :   switch(lz)
     492             :   {
     493      259701 :     case 2: return icopy(x); /* z = 0, wasteful copy */
     494    27618618 :     case 3: return addmulii_lg3(x, y, z);
     495     2189521 :     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   758176767 : addmulii_inplace(GEN x, GEN y, GEN z)
     501             : {
     502             :   long lz;
     503   758176767 :   if (lgefint(y) == 2) return x;
     504   207366728 :   lz = lgefint(z);
     505   207366728 :   switch(lz)
     506             :   {
     507           0 :     case 2: return x;
     508   190539587 :     case 3: return addmulii_lg3(x, y, z);
     509    16827141 :     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  2290117383 : 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  2290117383 :   if (!z) return -1;
     523             : #ifdef LONG_IS_64BIT
     524  2044175009 :   if (! (z&0xffffffff)) { s = 32; z >>=32; } else s = 0;
     525             : #endif
     526  2290117383 :   z |= ~z + 1;
     527  2290117383 :   z += z << 4;
     528  2290117383 :   z += z << 6;
     529  2290117383 :   z ^= z << 16; /* or  z -= z<<16 */
     530             : #ifdef LONG_IS_64BIT
     531  2044175009 :   return s + tab[(z&0xffffffff)>>26];
     532             : #else
     533   245942374 :   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     2508892 : divir(GEN x, GEN y)
     553             : {
     554             :   GEN z;
     555     2508892 :   long ly = lg(y), lx = lgefint(x);
     556             :   pari_sp av;
     557             : 
     558     2508892 :   if (ly == 2) pari_err_INV("divir",y);
     559     2508892 :   if (lx == 2) return div0r(y);
     560     2418620 :   if (lx == 3) {
     561     1254995 :     z = divur(x[2], y);
     562     1254995 :     if (signe(x) < 0) togglesign(z);
     563     1254995 :     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     1269973 : divur(ulong x, GEN y)
     572             : {
     573             :   pari_sp av;
     574     1269973 :   long ly = lg(y);
     575             :   GEN z;
     576             : 
     577     1269973 :   if (ly == 2) pari_err_INV("divur",y);
     578     1269973 :   if (!x) return div0r(y);
     579     1269973 :   if (ly > INVNEWTON_LIMIT) {
     580         493 :     av = avma; z = invr(y);
     581         493 :     if (x == 1) return z;
     582         493 :     return gerepileuptoleaf(av, mulur(x, z));
     583             :   }
     584     1269480 :   z = cgetr(ly); av = avma;
     585     1269480 :   affrr(divrr(utor(x,ly+1), y), z);
     586     1269480 :   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    10831155 : invr_basecase(GEN y)
     612             : {
     613    10831155 :   long ly = lg(y);
     614    10831155 :   GEN z = cgetr(ly);
     615    10831155 :   pari_sp av = avma;
     616    10831155 :   affrr(divrr(real_1(ly+1), y), z);
     617    10831155 :   avma = av; return z;
     618             : }
     619             : /* returns 1/b, Newton iteration */
     620             : GEN
     621    10831155 : invr(GEN b)
     622             : {
     623    10831155 :   const long s = 6;
     624    10831155 :   long i, p, l = lg(b);
     625             :   GEN x, a;
     626             :   ulong mask;
     627             : 
     628    10831155 :   if (l <= maxss(INVNEWTON_LIMIT, (1L<<s) + 2)) {
     629    10828153 :     if (l == 2) pari_err_INV("invr",b);
     630    10828153 :     return invr_basecase(b);
     631             :   }
     632        3002 :   mask = quadratic_prec_mask(l-2);
     633        3002 :   for(i=0, p=1; i<s; i++) { p <<= 1; if (mask & 1) p--; mask >>= 1; }
     634        3002 :   x = cgetr(l);
     635        3002 :   a = rcopy(b); a[1] = _evalexpo(0) | evalsigne(1);
     636        3002 :   affrr(invr_basecase(rtor(a, p+2)), x);
     637       10254 :   while (mask > 1)
     638             :   {
     639        4250 :     p <<= 1; if (mask & 1) p--;
     640        4250 :     mask >>= 1;
     641        4250 :     setlg(a, p + 2);
     642        4250 :     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        4250 :     affrr(addrr(x, mulrr(x, subsr(1, mulrr(a,x)))), x);
     646        4250 :     avma = (pari_sp)a;
     647             :   }
     648        3002 :   x[1] = (b[1] & SIGNBITS) | evalexpo(expo(x)-expo(b));
     649        3002 :   avma = (pari_sp)x; return x;
     650             : }
     651             : 
     652             : GEN
     653  1370027360 : modii(GEN x, GEN y)
     654             : {
     655  1370027360 :   switch(signe(x))
     656             :   {
     657   342420867 :     case 0: return gen_0;
     658   705244882 :     case 1: return remii(x,y);
     659             :     default:
     660             :     {
     661   322361611 :       pari_sp av = avma;
     662   322361611 :       (void)new_chunk(lgefint(y));
     663   322354599 :       x = remii(x,y); avma=av;
     664   322360033 :       if (x==gen_0) return x;
     665   301106684 :       return subiispec(y+2,x+2,lgefint(y)-2,lgefint(x)-2);
     666             :     }
     667             :   }
     668             : }
     669             : 
     670             : void
     671      518858 : modiiz(GEN x, GEN y, GEN z)
     672             : {
     673      518858 :   const pari_sp av = avma;
     674      518858 :   affii(modii(x,y),z); avma=av;
     675      518858 : }
     676             : 
     677             : GEN
     678     3469307 : divrs(GEN x, long y)
     679             : {
     680             :   GEN z;
     681     3469307 :   if (y < 0)
     682             :   {
     683      348349 :     z = divru(x, (ulong)-y);
     684      348349 :     togglesign(z);
     685             :   }
     686             :   else
     687     3120958 :     z = divru(x, (ulong)y);
     688     3469307 :   return z;
     689             : }
     690             : 
     691             : GEN
     692   490855359 : divru(GEN x, ulong y)
     693             : {
     694   490855359 :   long i, lx, sh, e, s = signe(x);
     695             :   ulong garde;
     696             :   GEN z;
     697             :   LOCAL_HIREMAINDER;
     698             : 
     699   490855359 :   if (!y) pari_err_INV("divru",gen_0);
     700   490855359 :   if (!s) return real_0_bit(expo(x) - expu(y));
     701   490796344 :   if (!(y & (y-1))) /* power of 2 */
     702             :   {
     703    34694443 :     if (y == 1) return rcopy(x);
     704    32911365 :     return shiftr(x, -expu(y));
     705             :   }
     706   456101901 :   e = expo(x);
     707   456101901 :   lx = lg(x);
     708   456101901 :   z = cgetr(lx);
     709   456101901 :   if (lx == 3)
     710             :   {
     711   276325808 :     if (y <= uel(x,2))
     712             :     {
     713   276325652 :       hiremainder = 0;
     714   276325652 :       z[2] = divll(x[2],y);
     715             :       /* we may have hiremainder != 0 ==> garde */
     716   276325652 :       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   179776093 :     ulong yp = get_Fl_red(y);
     729   179776093 :     if (y <= uel(x,2))
     730             :     {
     731   179773636 :       hiremainder = 0;
     732   179773636 :       for (i=2; i<lx; i++) z[i] = divll_pre(x[i],y,yp);
     733             :       /* we may have hiremainder != 0 ==> garde */
     734   179773636 :       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   456101901 :   sh=bfffo(z[2]); /* z[2] != 0 */
     747   456101901 :   if (sh) shift_left(z,z, 2,lx-1, garde,sh);
     748   456101901 :   z[1] = evalsigne(s) | evalexpo(e-sh);
     749   456101901 :   if ((garde << sh) & HIGHBIT) roundr_up_ip(z, lx);
     750   456101901 :   return z;
     751             : }
     752             : 
     753             : GEN
     754    49910094 : truedvmdii(GEN x, GEN y, GEN *z)
     755             : {
     756             :   pari_sp av;
     757             :   GEN r, q, *gptr[2];
     758    49910094 :   if (!is_bigint(y)) return truedvmdis(x, itos(y), z);
     759      668639 :   if (z == ONLY_REM) return modii(x,y);
     760             : 
     761      668639 :   av = avma;
     762      668639 :   q = dvmdii(x,y,&r); /* assume that r is last on stack */
     763      668639 :   switch(signe(r))
     764             :   {
     765             :     case 0:
     766       45804 :       if (z) *z = gen_0;
     767       45804 :       return q;
     768             :     case 1:
     769      508344 :       if (z) *z = r; else cgiv(r);
     770      508344 :       return q;
     771      114491 :     case -1: break;
     772             :   }
     773      114491 :   q = addis(q, -signe(y));
     774      114491 :   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    49242107 : truedvmdis(GEN x, long y, GEN *z)
     782             : {
     783    49242107 :   pari_sp av = avma;
     784             :   long r;
     785             :   GEN q;
     786             : 
     787    49242107 :   if (z == ONLY_REM) return modis(x, y);
     788    49242107 :   q = divis_rem(x,y,&r);
     789             : 
     790    49242107 :   if (r >= 0)
     791             :   {
     792    44159898 :     if (z) *z = utoi(r);
     793    44159898 :     return q;
     794             :   }
     795     5082209 :   q = gerepileuptoint(av, addis(q, (y < 0)? 1: -1));
     796     5082209 :   if (z) *z = utoi(r + labs(y));
     797     5082209 :   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    72516038 : int2n(long n) {
     819             :   long i, m, l;
     820             :   GEN z;
     821    72516038 :   if (n < 0) return gen_0;
     822    72514966 :   if (n == 0) return gen_1;
     823             : 
     824    71869565 :   l = dvmdsBIL(n, &m) + 3;
     825    71869564 :   z = cgetipos(l);
     826    71869625 :   for (i = 2; i < l; i++) z[i] = 0;
     827    71869625 :   *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     6071539 : int2u(ulong n) {
     833             :   ulong i, m, l;
     834             :   GEN z;
     835     6071539 :   if (n == 0) return gen_1;
     836             : 
     837     6071537 :   l = dvmduBIL(n, &m) + 3;
     838     6071535 :   z = cgetipos(l);
     839     6071523 :   for (i = 2; i < l; i++) z[i] = 0;
     840     6071523 :   *int_MSW(z) = 1UL << m; return z;
     841             : }
     842             : 
     843             : GEN
     844   818846478 : shifti(GEN x, long n)
     845             : {
     846   818846478 :   long s = signe(x);
     847             :   GEN y;
     848             : 
     849   818846478 :   if(s == 0) return gen_0;
     850   746609908 :   y = shiftispec(x + 2, lgefint(x) - 2, n);
     851   746540172 :   if (signe(y)) setsigne(y, s);
     852   746540172 :   return y;
     853             : }
     854             : 
     855             : /* actual operations will take place on a+2 and b+2: we strip the codewords */
     856             : GEN
     857  7422013034 : mulii(GEN a,GEN b)
     858             : {
     859             :   long sa,sb;
     860             :   GEN z;
     861             : 
     862  7422013034 :   sa=signe(a); if (!sa) return gen_0;
     863  4895753958 :   sb=signe(b); if (!sb) return gen_0;
     864  3275988770 :   if (sb<0) sa = -sa;
     865  3275988770 :   z = muliispec(a+2,b+2, lgefint(a)-2,lgefint(b)-2);
     866  3276785753 :   setsigne(z,sa); return z;
     867             : }
     868             : 
     869             : GEN
     870  1104424557 : 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     3968706 : usqrt(ulong a)
     876             : {
     877     3968706 :   ulong x = (ulong)sqrt((double)a);
     878             : #ifdef LONG_IS_64BIT
     879     2864918 :   if (x > LOWMASK || x*x > a) x--;
     880             : #endif
     881     3968706 :   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     5679808 : dbltor(double x)
     916             : {
     917             :   GEN z;
     918             :   long e;
     919             :   union { double f; ulong i; } fi;
     920     5679808 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
     921     5679808 :   const int exp_mid = 0x3ff;/* exponent bias */
     922     5679808 :   const int expo_len = 11; /* number of bits of exponent */
     923             : 
     924     5679808 :   if (x==0.) return real_0_bit(-exp_mid);
     925     5679768 :   fi.f = x; z = cgetr(DEFAULTPREC);
     926             :   {
     927     5679768 :     const ulong a = fi.i;
     928             :     ulong A;
     929     5679768 :     e = ((a & (HIGHBIT-1)) >> mant_len) - exp_mid;
     930     5679768 :     if (e == exp_mid+1) pari_err_OVERFLOW("dbltor [NaN or Infinity]");
     931     5679768 :     A = a << expo_len;
     932     5679768 :     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     5679768 :       z[2] = HIGHBIT | A;
     940     5679768 :     z[1] = _evalexpo(e) | evalsigne(x<0? -1: 1);
     941             :   }
     942     5679768 :   return z;
     943             : }
     944             : 
     945             : double
     946    24026046 : rtodbl(GEN x)
     947             : {
     948    24026046 :   long ex,s=signe(x);
     949             :   ulong a;
     950             :   union { double f; ulong i; } fi;
     951    24026046 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
     952    24026046 :   const int exp_mid = 0x3ff;/* exponent bias */
     953    24026046 :   const int expo_len = 11; /* number of bits of exponent */
     954             : 
     955    24026046 :   if (!s || (ex=expo(x)) < - exp_mid) return 0.0;
     956             : 
     957             :   /* start by rounding to closest */
     958    23564365 :   a = (x[2] & (HIGHBIT-1)) + 0x400;
     959    23564365 :   if (a & HIGHBIT) { ex++; a=0; }
     960    23564365 :   if (ex >= exp_mid) pari_err_OVERFLOW("t_REAL->double conversion");
     961    23564365 :   fi.i = ((ex + exp_mid) << mant_len) | (a >> expo_len);
     962    23564365 :   if (s<0) fi.i |= HIGHBIT;
     963    23564365 :   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      956234 : dbltor(double x)
    1009             : {
    1010             :   GEN z;
    1011             :   long e;
    1012             :   union { double f; ulong i[2]; } fi;
    1013      956234 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
    1014      956234 :   const int exp_mid = 0x3ff;/* exponent bias */
    1015      956234 :   const int expo_len = 11; /* number of bits of exponent */
    1016      956234 :   const int shift = mant_len-32;
    1017             : 
    1018      956234 :   if (x==0.) return real_0_bit(-exp_mid);
    1019      956230 :   fi.f = x; z = cgetr(DEFAULTPREC);
    1020             :   {
    1021      956230 :     const ulong a = fi.i[INDEX0];
    1022      956230 :     const ulong b = fi.i[INDEX1];
    1023             :     ulong A, B;
    1024      956230 :     e = ((a & (HIGHBIT-1)) >> shift) - exp_mid;
    1025      956230 :     if (e == exp_mid+1) pari_err_OVERFLOW("dbltor [NaN or Infinity]");
    1026      956230 :     A = b >> (BITS_IN_LONG-expo_len) | (a << expo_len);
    1027      956230 :     B = b << expo_len;
    1028      956230 :     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      956230 :       z[3] = B;
    1049      956230 :       z[2] = HIGHBIT | A;
    1050             :     }
    1051      956230 :     z[1] = _evalexpo(e) | evalsigne(x<0? -1: 1);
    1052             :   }
    1053      956230 :   return z;
    1054             : }
    1055             : 
    1056             : double
    1057     3885996 : rtodbl(GEN x)
    1058             : {
    1059     3885996 :   long ex,s=signe(x),lx=lg(x);
    1060             :   ulong a,b,k;
    1061             :   union { double f; ulong i[2]; } fi;
    1062     3885996 :   const int mant_len = 52;  /* mantissa bits (excl. hidden bit) */
    1063     3885996 :   const int exp_mid = 0x3ff;/* exponent bias */
    1064     3885996 :   const int expo_len = 11; /* number of bits of exponent */
    1065     3885996 :   const int shift = mant_len-32;
    1066             : 
    1067     3885996 :   if (!s || (ex=expo(x)) < - exp_mid) return 0.0;
    1068             : 
    1069             :   /* start by rounding to closest */
    1070     3809928 :   a = x[2] & (HIGHBIT-1);
    1071     3809928 :   if (lx > 3)
    1072             :   {
    1073     3696264 :     b = x[3] + 0x400UL; if (b < 0x400UL) a++;
    1074     3696264 :     if (a & HIGHBIT) { ex++; a=0; }
    1075             :   }
    1076      113664 :   else b = 0;
    1077     3809928 :   if (ex >= exp_mid) pari_err_OVERFLOW("t_REAL->double conversion");
    1078     3809928 :   ex += exp_mid;
    1079     3809928 :   k = (a >> expo_len) | (ex << shift);
    1080     3809928 :   if (s<0) k |= HIGHBIT;
    1081     3809928 :   fi.i[INDEX0] = k;
    1082     3809928 :   fi.i[INDEX1] = (a << (BITS_IN_LONG-expo_len)) | (b >> expo_len);
    1083     3809928 :   return fi.f;
    1084             : }
    1085             : #endif /* LONG_IS_64BIT */
    1086             : 

Generated by: LCOV version 1.11