Ternary system

from Wikipedia, the free encyclopedia

The ternary system , 3-adic system , also called the three-way system and rarely triadic system , is a system of place values ​​based on base 3. It comes in three varieties, as a normal ternary system with the digits 0, 1 and 2 and as a balanced ternary system with the digits 0, 1 and −1; The negaternary system with the negative base −3 and the digits 0, 1 and 2 is of more theoretical interest .

A ternary digit is also called a trit (in analogy to the bit ) and a corresponding group of six trits is called a tryte . In 1958 the Setun computer was developed in the Soviet Union , which calculated with ternary numbers.

Usually

In the ordinary ternary system , a number is represented by a combination of the digits 0, 1 and 2. Since it can be confused with other numerical representations, especially with the decimal system , a ternary number is indicated by an appended subscript 3. The decimal number corresponding to a ternary number can be calculated as in the following example:

If you solve the powers , the equation looks like this:

The corresponding general formula is

.

Here the ternary digit is in the place ( i.e. either 0, 1 or 2), the number of decimal places and the number of the highest place. is then the result, i.e. the value of the ternary number. This formula is the same as the first and second linear formulas in the article, just presented differently.

More examples of numbers in the ternary system and their counterparts in the decimal system:

  • 12 3 = 5
  • 112 3 = 14
  • 121 3 = 16

Numbers in the normal ternary system, like numbers in other place value systems, can be represented in a table for understanding. The number in a field indicates how often the number in the column name is counted. For example, if there is a "2" in a field in the "3" column, you have to calculate "3 + 3" or "2 ∙ 3", for "1" under "27" simply "1 ∙ 27". At the end you add up all the individual results of the interim calculations ("2 ∙ 3", "1 ∙ 27") and get the decimal number. Zeros that are to the left of the first 1 or 2 (leading zeros) are not written down in the usual notation (column compound ternary number ).

Number in decimal 27 (3 3 ) 9 (3 2 ) 3 (3 1 ) 1 (3 0 ) composite ternary number
32 1 0 1 2 1012
46 1 2 0 1 1201
3 0 0 1 0 10
7th 0 0 2 1 21st
5 0 0 1 2 12
14th 0 1 1 2 112

Balanced

A number in the balanced ternary system is represented by a combination of the digits 0, 1 and −1. The number −1 is represented in this article by 1 , another representation is a letter T, or an inverted (180 ° rotated) number 1: "1". If confusion can occur, a balanced ternary number is indicated by an appended subscript" 3bal ".

Examples of numbers in the balanced ternary system and their counterparts in the decimal system:

  • 1 1 1 3bal = 5
  • 1 1 0 3bal = 6

In the balanced ternary system you don't need a sign . To go to the negative number, swap all digits 1 with 1 and all digits 1 with 1.

1 11 3bal = −5

The sign of a number is that of its most significant ternary digit:

( 1 11 3bal ) = 1 3bal = −1 dec .

Here too, as shown for the ordinary ternary system, the corresponding decimal number can be calculated:

1 1 0 3bal = 1 3 2 + (−1) 3 1 + 0 3 0 = 1 9 + (−1) 3 + 0 1 = 6 dec .

The very numbers that are an integer plus 1/2 times a power of 3 have two representations, e.g. B.

0, 1 3bal = 1, 1 3bal = 1/2,

The overline means that the group of digits below (the period ) must be repeated indefinitely. In contrast to the usual place value systems on the basis , in which precisely the terminating representations have two different representations, here it is the fractions , the representation of which, however, does not terminate.

Knuth points out that in balanced systems, rounding and truncating are the same operation with the same result.

A computer based on the balanced ternary system and the balanced ternary logic was the Setun ( Russian Сетунь ) (see introduction).

Comparison with the decimal system and the binary system

Decimal Binary Ternary Ternary (balanced) Decimal Binary Ternary Ternary (balanced)
dec am 3 bal3 dec am 3 bal3
0 0 0 0
1 1 1 1 −1 −1 −1 1
2 10 2 1 1 −2 -10 -2 1 1
3 11 10 10 −3 –11 -10 1 0
4th 100 11 11 −4 -100 –11 11
5 101 12 1 11 −5 -101 -12 1 11
6th 110 20th 1 1 0 −6 -110 -20 1 10
7th 111 21st 1 1 1 −7 -111 -21 1 1 1
8th 1000 22nd 10 1 −8 -1000 -22 1 01
9 1001 100 100 −9 -1001 -100 1 00
10 1010 101 101 −10 -1010 -101 1 0 1
11 1011 102 11 1 −11 -1011 -102 11 1
12 1100 110 110 −12 -1100 -110 11 0
13 1101 111 111 −13 -1101 -111 111

Ternary code with comma

If each digit is coded as 2 binary digits in the ternary system, e.g. 0: = 00 1: =10 and 2: = 01, then the combination can be used 11as a separator, as a “comma”, between two non-negative numbers represented in this way. For example, the sequence of numbers results in the character string . The individual code words are variable in length and little-endian . 1011001011100111

With an assumed geometric distribution of the natural numbers , this ternary comma code .

literature

Individual evidence

  1. Nikolay Petrovich Brusentsov , José Ramil Alvarez: Ternary Computers: The Setun and the Setun 70 . In: J. Impagliazzo, E. Proydakov (Eds.): SoRuCom 2006, IFIP AICT 357 . IFIP International Federation for Information Processing 2011, pp. 74-80 (accessed May 9, 2016).
  2. Knuth
  3. NAKrinitsky: Chapter 10 Program-controlled machine Zeitun . In: MRShura-Bura (Ed.): Programming ( ru ) 1963.

See also

Web links