(phixonline)-->
with javascript_semantics
function mul(string a, b)
bool bSign = false
if a[1]='-' then {bSign,a} = {not bSign, a[2..$]} end if
if b[1]='-' then {bSign,b} = {not bSign, b[2..$]} end if
string res = repeat('0',length(a)+length(b))
--
-- Note that i,j,k are used as negative indexes, working
-- from the right hand least significant digit leftwards.
--
for i=1 to length(a) do
integer j=1, k=i, c=0
while j<=length(b) or c do
c += res[-k]-'0'
if j<=length(b) then
c += (a[-i]-'0')*(b[-j]-'0')
j += 1
end if
res[-k] = remainder(c,10)+'0'
c = floor(c/10)
k += 1
end while
end for
res = trim_head(res,"0")
if bSign then res = '-'&res end if
return res
end function
?mul("18446744073709551616","18446744073709551616")