Long multiplication: Difference between revisions
→{{header|J}}: formatting to improve clarity
(→{{header|J}}: formatting to improve clarity) |
|||
Line 643:
=={{header|J}}==
<lang j> ((+ 10x&*)/@|.@(,.&.":@[ +//.@(*/) ,.&.":@]))/ ,~2x^64▼
340282366920938463463374607431768211456</lang>▼
▲ ((+10x&*)/@|.@(,.&.":@[+//.@(*/),.&.":@]))/ ,~2x^64
* digits: <code>,.&.": y</code>▼
▲340282366920938463463374607431768211456
<lang j> ,.&.": 123▼
1 2 3</lang>▼
▲* digits: ,.&.": y
* polynomial multiplication: <code>x (+//.@(*/)) y</code> '''ref.''' [http://www.jsoftware.com/help/dictionary/samp23.htm]▼
<lang j> 1 2 3 (+//.@(*/)) 1 2 3▼
▲ ,.&.": 123
1 4 10 12 9</lang>▼
▲1 2 3
<lang j> (+ 10x&*)/|. 1 4 10 12 9▼
▲* polynomial multiplication: x (+//.@(*/)) y '''ref.''' [http://www.jsoftware.com/help/dictionary/samp23.htm]
15129</lang>▼
▲ 1 2 3 (+//.@(*/)) 1 2 3
<lang j> (10x #. ,.&.":@[ +//.@(*/) ,.&.":@])/ ,~2x^64▼
▲1 4 10 12 9
340282366920938463463374607431768211456</lang>▼
▲* building the decimal result: (+10x&*)/|. y
▲ (+10x&*)/|. 1 4 10 12 9
▲15129
▲or using the primitive dyad #. instead of (+10x&*)/@|.
▲ (10x #.,.&.":@[+//.@(*/),.&.":@])/ ,~2x^64
▲340282366920938463463374607431768211456
Writing directly:
<lang j> (2x^64)*(2x^64)▼
340282366920938463463374607431768211456</lang>▼
▲(2x^64)*(2x^64)
▲340282366920938463463374607431768211456
=={{header|JavaScript}}==
|