Long multiplication: Difference between revisions

Content added Content deleted
(→‎{{header|Arturo}}: Fixed it with an actual long multiplication program.)
(Add APL)
Line 990: Line 990:
2^128: 340282366920938463463374607431768211456
2^128: 340282366920938463463374607431768211456
</pre>
</pre>

=={{header|APL}}==
{{works with|Dyalog APL}}

This function takes two digit vectors of arbitrary size.
<syntaxhighlight lang="apl">longmul←{⎕IO←0
sz←⌈/≢¨x y←↓⌽↑⌽¨⍺⍵
ds←+⌿↑(⌽⍳sz)⌽¨↓(¯2×sz)↑[1]x∘.×y
mlt←{(1⌽⌊⍵÷10)+10|⍵}⍣≡⊢ds
0=≢mlt←(∨\0≠mlt)/mlt:,0
mlt
}</syntaxhighlight>

{{out}}

<syntaxhighlight lang="apl"> ⎕←input←longmul⍣63⍨⊢,2 ⍝ construct 2*64
1 8 4 4 6 7 4 4 0 7 3 7 0 9 5 5 1 6 1 6
⎕←longmul⍨input ⍝ calculate 2*128
3 4 0 2 8 2 3 6 6 9 2 0 9 3 8 4 6 3 4 6 3 3 7 4 6 0 7 4 3 1 7 6 8 2 1 1 4 5 6</syntaxhighlight>


=={{header|Arturo}}==
=={{header|Arturo}}==