Charles Greathouse on Tue, 03 Dec 2013 23:41:06 +0100


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

Re: reverse of digits()


I see convi here:

GEN
sumdigits(GEN n)
{
  pari_sp av = avma;
  ulong s, *res;
  long l;

  if (typ(n) != t_INT) pari_err_TYPE("sumdigits", n);
  l = lgefint(n);
  switch(l)
  {
    case 2: return gen_0;
    case 3: return utoipos(sumdigitsu(n[2]));
  }
  res = convi(n, &l);

in the git HEAD.

Charles Greathouse
Analyst/Programmer
Case Western Reserve University


On Tue, Dec 3, 2013 at 5:05 PM, Bill Allombert <Bill.Allombert@math.u-bordeaux1.fr> wrote:
On Tue, Dec 03, 2013 at 11:25:17AM -0500, Charles Greathouse wrote:
> I think there's a reason, but not a good reason: the current code uses
> convi to convert the number to base 10^9, so of course this is base-10
> specific. (I guess this is memory-inefficient for 64-bit systems?)

I suggest you check out the code, it does not use convi.

However, what is the purpose of sumdigits ?

Cheers
Bill.