A ternary code is a way of representing data in the form of a combination of three characters , usually denoted by the numbers 0, 1, 2.
The ternary code can be non-positional and positional .
It is known from combinatorics that, in the case of non-positional coding , the number of combinations (codes) is the number of combinations with repetitions from by and equal to the binomial coefficient :
-
- , [possible states (codes)], i.e.
described by a parabola :
- , [possible states (codes)], where
- - the number of ternary discharges ( throws , trit s).
For example, in a non-position coding system, in one 3-grit code (n = 3) the number of possible states (codes) is equal to:
- , [possible states (codes)].
In the case of positional coding , the number of combinations (codes) of the n- digit ternary code is equal to the number of placements with repetitions :
- where
- - number of codes
- - the number of bits of the ternary code.
Using two ternary digits and position coding, you can encode any objects using nine different combinations: 00 01 02 10 11 12 20 21 22 (with non-position coding of combinations - 6, because three pairs are 01 and 10, 02 and 20, 12 and 21 count as three combinations); using three ternary digits - using twenty-seven different combinations: 000 001 002 010 011 012 020 021 022 100 101 102 110 111 112 120 121 122 200 201 202 210 211 212 220 221 222 (with non-positional encoding of combinations - 10), and so Further.
As the positional ternary code increases by 1, the number of different combinations in the positional ternary code triple.
Ternary codes are combinations of three elements and are not a ternary number system , but are used in one or another version of ternary number systems as a basis. Moreover, they can be used to encode numbers in number systems with any base. However, for a number system with a base of two (that is, for binary) they are redundant and can only be partially used.
When encoding alphanumeric characters ( signs ), ternary code does not assign weighting factors, as is done in number systems in which the ternary code is used to represent numbers , and only the serial number of the code from the set of repetition arrangements is used .
| numerical value | ternary code |
|---|---|
| 0 | 00 |
| one | 01 |
| 2 | 02 |
| 3 | ten |
| four | eleven |
| five | 12 |
| 6 | 20 |
| 7 | 21 |
| eight | 22 |
See also
- Binary code
- Trinity number system
- Trit