Ternary or trinary is the base-3 numeral system. Analogous to a bit, a ternary digit is a trit (trinary digit). One trit contains log23 (about 1.58496) bits of information. Although ternary most often refers to a system in which the three digits, 0, 1, and 2, are all nonnegative integers, the adjective also lends its name to the balanced ternary system, used in comparison logic and ternary computers.
Comparison to other radixes
Compared to decimal and binary
Representations of integer numbers in ternary do not get uncomfortably lengthy as quickly as in binary. For example, decimal 365 corresponds to binary 101101101 (9 digits) and to ternary 111112 (6 digits). However, they are still far less compact than the corresponding representations in bases such as decimal — see below for a compact way to codify ternary using nonary and septemvigesimal.
As for rational numbers, ternary offers a convenient way to represent one third (as opposed to its cumbersome representation as an infinite string of recurring digits in decimal); but a major drawback is that, in turn, ternary does not offer a finite representation for the most basic fraction: one half (and thus, neither for one quarter, one sixth, one eighth, one tenth, etc.), because 2 is not a prime factor of the base.
Sum of the digits in ternary as opposed to binary
Whereas in binary, where the sum of all previous digit values before 2n can be found using the formula 2n-1, in ternary the following formula can be used: (3n-1)/2.
An example is where in binary the fourth digit has a value of 8, the sum of all the binary numbers before 8 can be found out using the above formula as 23-1, which is 7. In ternary the fourth digit has a value of 27 and the sum of all previous ternary numbers can be found out using the above formula, as (33-1)/2, which is 13.
Full article ▸