Task

Explicitly implement   long multiplication.

This is one possible approach to arbitrary-precision integer algebra.



For output, display the result of    264 * 264.

Optionally, verify your result against builtin arbitrary precision support.

The decimal representation of    264    is:

18,446,744,073,709,551,616

The output of    264 * 264    is    2128,    and is:

340,282,366,920,938,463,463,374,607,431,768,211,456



long(a,b)={
  a=eval(Vec(a));
  b=eval(Vec(b));
  my(c=vector(#a+#b),carry=0);
  for(i=1,#a,
    for(j=1,#b,
      c[i+j]+=a[i]*b[j]
    )
  );
  forstep(i=#c,1,-1,
    c[i] += carry;
    carry = c[i] \ 10;
    c[i] = c[i] % 10
  );
  for(i=1,#c,
    if(c[i], return(concat(apply(s->Str(s),vector(#c+1-i,j,c[i+j-1])))))
  );
  "0"
};
long("18446744073709551616","18446744073709551616")