record largint(coeff,nextl)

procedure add(g1,g2,carry)
   local sum
   /carry := largint(0)	# default carry
   if /g1 & /g2 then return if carry.coeff ~= 0 then carry
   else &null
   if /g1 then return add(carry,g2)
   if /g2 then return add(g1,carry)
   sum := g1.coeff + g2.coeff + carry.coeff
   carry := largint(sum / base)
   return largint(sum % base,add(g1.nextl,g2.nextl,carry))
end

procedure large(s)
   if *s <= segsize then return largint(integer(s))
   else return largint(right(s,segsize),
      large(left(s,*s - segsize)))
end

procedure lstring(g)
   local s
   if /g.nextl then s := g.coeff
   else s := lstring(g.nextl) || right(g.coeff,segsize,"0")
   s ?:= (tab(upto(~'0') | -1) & tab(0))
   return s
end
