Long multiplication: Difference between revisions
Content added Content deleted
m (→{{header|C sharp|C#}}: corrected output) |
m (→{{header|Visual Basic .NET}}: corrected typo) |
||
Line 5,398: | Line 5,398: | ||
y.hi += Math.Floor(a / hm) : y.lo += (a Mod hm) * hm ' increment hi and lo parts with high and low parts of the mid-term |
y.hi += Math.Floor(a / hm) : y.lo += (a Mod hm) * hm ' increment hi and lo parts with high and low parts of the mid-term |
||
While y.lo > mx : y.lo -= mx : y.hi += 1 : End While ' check for overflow, adjust both parts as needed |
While y.lo > mx : y.lo -= mx : y.hi += 1 : End While ' check for overflow, adjust both parts as needed |
||
WriteLine(" is {0,75} (which {1} match the |
WriteLine(" is {0,75} (which {1} match the BigInteger computation)" & vbLf, |
||
toStr(y, True), If(BS.ToString() = toStr(y), "does", "fails to")) |
toStr(y, True), If(BS.ToString() = toStr(y), "does", "fails to")) |
||
Next |
Next |
||
Line 5,406: | Line 5,406: | ||
{{out}}Shown are the prescribed output and the maximum power of two that can be squared by this '''''bd''''' structure without overflowing. |
{{out}}Shown are the prescribed output and the maximum power of two that can be squared by this '''''bd''''' structure without overflowing. |
||
<pre>The square of (2^64): 18,446,744,073,709,551,616 |
<pre>The square of (2^64): 18,446,744,073,709,551,616 |
||
is 340,282,366,920,938,463,463,374,607,431,768,211,456 (which does match the |
is 340,282,366,920,938,463,463,374,607,431,768,211,456 (which does match the BigInteger computation) |
||
The square of (2^94): 19,807,040,628,566,084,398,385,987,584 |
The square of (2^94): 19,807,040,628,566,084,398,385,987,584 |
||
is 392,318,858,461,667,547,739,736,838,950,479,151,006,397,215,279,002,157,056 (which does match the |
is 392,318,858,461,667,547,739,736,838,950,479,151,006,397,215,279,002,157,056 (which does match the BigInteger computation)</pre> |
||
=={{header|Wren}}== |
=={{header|Wren}}== |