Multiply (Ternary): Difference between revisions

From TernaryWiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
Ternary multiplication works similarly to decimal long multiplication. The multiplicand is multiplied by each digit of the multiplier. Which results in a list of partial products, and each next partial product is multiplied by 10; shifted to the left. The list of partial products is then added together for the total product.
Ternary multiplication works similarly to decimal long multiplication. The multiplicand is multiplied by each digit of the multiplier, which results in a list of partial products. Each next partial product is shifted over by one place value. The list of partial products is then added together for the final product.


The difference with ternary is the multiplicand is EORed by each digit of the multiplier. This results in all the partial products being the A input buffered, zeroed, or negated depending on the value of B at that digit. Each partial product is shifted to the left.
The difference with ternary is the tryte multiplicand is [[EOR (Ternary Gate)|EORed]] by each trit of the multiplier. This results in all the partial products being the A input buffered, zeroed, or [[NEG (Ternary Gate)|negated]] depending on the value of B at that digit. Each partial product is also shifted to the left.


All the partial products are then added up for the final total.
All the partial products are then added up for the final product.


== Ternary Multiplication Example ==
== Ternary Multiplication Example ==
{| class="wikitable" style="text-align: center; font-family: monospace; font-size: 18px;"
{| class="wikitable" style="text-align: center; font-family: monospace; font-size: 18px;"
|+<big>4435 * 472</big>
|+ <big>4435 * 472 = 2,093,320</big>
!3<sup>16</sup>
!3<sup>17</sup>
!3<sup>15</sup>
! 3<sup>16</sup>
!3<sup>14</sup>
! 3<sup>15</sup>
!3<sup>13</sup>
! 3<sup>14</sup>
!3<sup>12</sup>
! 3<sup>13</sup>
!3<sup>11</sup>
! 3<sup>12</sup>
!3<sup>10</sup>
! 3<sup>11</sup>
!3<sup>9</sup>
! 3<sup>10</sup>
!3<sup>8</sup>
! 3<sup>9</sup>
!3<sup>7</sup>
! 3<sup>8</sup>
!3<sup>6</sup>
! 3<sup>7</sup>
!3<sup>5</sup>
! 3<sup>6</sup>
!3<sup>4</sup>
! 3<sup>5</sup>
!3<sup>3</sup>
! 3<sup>4</sup>
!3<sup>2</sup>
! 3<sup>3</sup>
!3<sup>1</sup>
! 3<sup>2</sup>
!3<sup>0</sup>
! 3<sup>1</sup>
! 3<sup>0</sup>
!
!
!B
! B
!
!
! colspan="9" |A
! colspan="9" | A
|-
|-
|
|
Line 38: Line 39:
|
|
|
|
| +
|
| -
| style="background-color:#88f;" | +
|0
| style="background-color:#f88;" | -
|0
| style="background-color:#8f8;" | 0
| +
| style="background-color:#8f8;" | 0
| -
| style="background-color:#88f;" | +
| +
| style="background-color:#f88;" | -
| -
| style="background-color:#88f;" | +
| +
| style="background-color:#f88;" | -
!=
| style="background-color:#88f;" | +
| +
! =
| style="background-color:#88f;" | +
| rowspan="9" |[[EOR (Ternary Gate)|EOR]]
| rowspan="9" |[[EOR (Ternary Gate)|EOR]]
| rowspan="9" | +
| rowspan="9" style="background-color:#88f;" | +
| rowspan="9" | -
| rowspan="9" style="background-color:#f88;" | -
| rowspan="9" |0
| rowspan="9" style="background-color:#8f8;" | 0
| rowspan="9" |0
| rowspan="9" style="background-color:#8f8;" | 0
| rowspan="9" | +
| rowspan="9" style="background-color:#88f;" | +
| rowspan="9" | -
| rowspan="9" style="background-color:#f88;" | -
| rowspan="9" | +
| rowspan="9" style="background-color:#88f;" | +
| rowspan="9" | -
| rowspan="9" style="background-color:#f88;" | -
| rowspan="9" | +
| rowspan="9" style="background-color:#88f;" | +
|-
|-
|
|
Line 67: Line 69:
|
|
|
|
| +
| -
|0
|0
| +
| -
| +
| -
| +
|
|
!=
| style="background-color:#88f;" | +
| +
| style="background-color:#f88;" | -
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
|↓
! =
| style="background-color:#88f;" | +
|-
|-
|
|
Line 85: Line 88:
|
|
|
|
|
| +
| -
|0
|0
| +
| -
| +
| -
| +
|
|
|
|
!=
| style="background-color:#88f;" | +
| +
| style="background-color:#f88;" | -
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
|↓
|↓
! =
| style="background-color:#88f;" | +
|-
|-
|
|
|
|
|
|
|
|
| -
| +
|0
|0
| -
| +
| -
| +
| -
|
|
|
|
|
|
!=
| style="background-color:#f88;" | -
| -
| style="background-color:#88f;" | +
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
|↓
|↓
|↓
! =
| style="background-color:#f88;" | -
|-
|-
|
|
|
|
|
|0
|0
|0
|0
|0
|0
|0
|0
|0
|
|
|
|
|
|
|
|
!=
| style="background-color:#8f8;" | 0
|0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
|↓
|↓
|↓
|↓
! =
| style="background-color:#8f8;" | 0
|-
|-
|
|
|
|
|
|
| -
| +
|0
|0
| -
| +
| -
| +
| -
|
|
|
| style="background-color:#f88;" | -
|
| style="background-color:#88f;" | +
|
| style="background-color:#8f8;" | 0
|
| style="background-color:#8f8;" | 0
!=
| style="background-color:#f88;" | -
| -
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
|↓
|
|
|
|↓
! =
| style="background-color:#f88;" | -
|-
|-
|
|
|
|
| +
| -
|0
|0
| +
| -
| +
| -
| +
|
|
|
| style="background-color:#88f;" | +
|
| style="background-color:#f88;" | -
|
| style="background-color:#8f8;" | 0
|
| style="background-color:#8f8;" | 0
|
| style="background-color:#88f;" | +
!=
| style="background-color:#f88;" | -
| +
| style="background-color:#88f;" | +
| style="background-color:#f88;" | -
| style="background-color:#88f;" | +
|↓
|
|
|
|
|↓
! =
| style="background-color:#88f;" | +
|-
|-
|
|0
|0
|0
|0
|0
|0
|0
|0
|0
|
|
|
|
|
|
|
|
|
!=
| style="background-color:#8f8;" | 0
|0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
|↓
|↓
|↓
|↓
|↓
|↓
|↓
! =
| style="background-color:#8f8;" | 0
|-
|-
|0
|0
|0
|0
|0
|0
|0
|0
|0
|
|
|
|
|
|
|
|
|
!=
| style="background-color:#8f8;" | 0
|0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
| style="background-color:#8f8;" | 0
|↓
|↓
|↓
|↓
|↓
|↓
|↓
|↓
! =
| style="background-color:#8f8;" | 0
|-
|-
! colspan="29" |
! colspan="30" |
----
----
|-
|-
|0
| style="background-color:#8f8;" | 0
|0
| style="background-color:#8f8;" | 0
|0
| style="background-color:#8f8;" | 0
| +
| style="background-color:#8f8;" | 0
| +
| style="background-color:#88f;" | +
|0
| style="background-color:#88f;" | +
| -
| style="background-color:#8f8;" | 0
| +
| style="background-color:#f88;" | -
| +
| style="background-color:#88f;" | +
|0
| style="background-color:#88f;" | +
|0
| style="background-color:#8f8;" | 0
| +
| style="background-color:#8f8;" | 0
| +
| style="background-color:#88f;" | +
| +
| style="background-color:#88f;" | +
| +
| style="background-color:#88f;" | +
|0
| style="background-color:#88f;" | +
| +
| style="background-color:#8f8;" | 0
!'''='''
| style="background-color:#88f;" | +
! =
| colspan="11" |<big>2,093,320</big>
| colspan="11" |<big>2,093,320</big>
|}
|}

Latest revision as of 10:39, 6 August 2025

Ternary multiplication works similarly to decimal long multiplication. The multiplicand is multiplied by each digit of the multiplier, which results in a list of partial products. Each next partial product is shifted over by one place value. The list of partial products is then added together for the final product.

The difference with ternary is the tryte multiplicand is EORed by each trit of the multiplier. This results in all the partial products being the A input buffered, zeroed, or negated depending on the value of B at that digit. Each partial product is also shifted to the left.

All the partial products are then added up for the final product.

Ternary Multiplication Example

4435 * 472 = 2,093,320
317 316 315 314 313 312 311 310 39 38 37 36 35 34 33 32 31 30 B A
+ - 0 0 + - + - + = + EOR + - 0 0 + - + - +
+ - 0 0 + - + - + = +
+ - 0 0 + - + - + = +
- + 0 0 - + - + - = -
0 0 0 0 0 0 0 0 0 = 0
- + 0 0 - + - + - = -
+ - 0 0 + - + - + = +
0 0 0 0 0 0 0 0 0 = 0
0 0 0 0 0 0 0 0 0 = 0

0 0 0 0 + + 0 - + + 0 0 + + + + 0 + = 2,093,320