Long multiplication: Difference between revisions
→{{header|ATS}}: Code simplification and slight commentary revision.
(ATS added ahead of →{{header|AutoHotkey}}) |
(→{{header|ATS}}: Code simplification and slight commentary revision.) |
||
Line 1,003:
I perform both binary long multiplication (designed for efficiency) and decimal arithmetic.
The example numbers, though fine for testing decimal arithmetic, are ''very'' bad for testing binary multiplication.
<syntaxhighlight lang="ats">
Line 1,087:
w : &array (uint32, m + n),
i : size_t i,
k : uint64)
:<!refwrt>
if i = m then
w[j + m] := u64u32 k
else
let
Line 1,102:
iloop (u, v, w, succ i, t >> 32)
end
in
jloop (u, v, w, succ j)
end
Line 1,329 ⟶ 1,328:
w : &array (char, m + n),
i : size_t i,
k : intBtwe (0, 9))
:<!refwrt>
if i = m then
w[pred n - j] := bcd2char k
else
let
Line 1,355 ⟶ 1,354:
iloop (u, v, w, succ i, t_div_10)
end
in
jloop (u, v, w, succ j)
end
|