Long multiplication: Difference between revisions
Content added Content deleted
(→{{header|J}}: simplify and reorganize) |
(→{{header|J}}: define verb longmult) |
||
Line 647: | Line 647: | ||
buildDecimal=: (+ 10x&*)/@|. |
buildDecimal=: (+ 10x&*)/@|. |
||
buildDecimal@polymult&digits/ |
longmult=: buildDecimal@polymult&digits/</lang> |
||
'''Example:''' |
|||
<lang j> longmult ,~ 2x^64 |
|||
340282366920938463463374607431768211456</lang> |
340282366920938463463374607431768211456</lang> |
||
'''Alternatives:'''<br> |
'''Alternatives:'''<br> |
||
The above |
The above may of course be accomplished without the verb definitions: |
||
<lang j> (+ 10x&*)/@|.@(+//.@(*/)&(,.&.":))/ ,~2x^64 |
<lang j> (+ 10x&*)/@|.@(+//.@(*/)&(,.&.":))/ ,~2x^64 |
||
340282366920938463463374607431768211456</lang> |
340282366920938463463374607431768211456</lang> |
||
Or using the primitive dyad <code>#.</code> instead of <code>(+ 10x&*)/@|.</code>: |
Or using the primitive dyad <code>#.</code> instead of <code>(+ 10x&*)/@|.</code> : |
||
<lang j> (10x&#.)@(+//.@(*/)&(,.&.":))/ ,~2x^64 |
<lang j> (10x&#.)@(+//.@(*/)&(,.&.":))/ ,~2x^64 |
||
340282366920938463463374607431768211456</lang> |
340282366920938463463374607431768211456</lang> |