|
|
BSD 4.3
record largint(coeff,link)
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.link,g2.link,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.link then s := g.coeff
else s := lstring(g.link) || right(g.coeff,segsize,"0")
s ?:= (tab(upto(~'0') | -1) & tab(0))
return s
end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.