Ternary numeral system


The ternary numeral system has three as its base. Analogous to a bit, a ternary digit is a trit. One trit is equivalent to log2 3 bits of information.
Although ternary most often refers to a system in which the three digits are all non–negative numbers, specifically,, and, the adjective also lends its name to the balanced ternary system, comprising the digits −1, 0 and +1, used in comparison logic and ternary computers.

Comparison to other bases

Representations of integer numbers in ternary do not get uncomfortably lengthy as quickly as in binary. For example, decimal 365 or senary 1405 corresponds to binary 101101101 and to ternary 111112. However, they are still far less compact than the corresponding representations in bases such as decimalsee below for a compact way to codify ternary using nonary and septemvigesimal.
Ternary12101112202122100
Binary1101110010111011110001001
Senary1234510111213
Decimal123456789
---------
Ternary101102110111112120121122200
Binary101010111100110111101111100001000110010
Senary141520212223242530
Decimal101112131415161718
---------
Ternary2012022102112122202212221000
Binary100111010010101101101011111000110011101011011
Senary313233343540414243
Decimal192021222324252627

Ternary110100100010000
Binary1111001110111010001
Senary131343213
Decimal1392781
Power3031323334
-----
Ternary1000001000000100000001000000001000000000
Binary1111001110110110011000100010111100110100001100110011100011
Senary104332131404350213231043
Decimal2437292187656119683
Power3536373839

As for rational numbers, ternary offers a convenient way to represent as same as senary ; but a major drawback is that, in turn, ternary does not offer a finite representation for , because 2 is not a prime factor of the base; as with base two, one-tenth is not representable exactly ; nor is one-sixth.
Fraction''''''''''''
Ternary0.0.10.0.0.00.0.0.010.0.0.00.
Binary0.10.0.010.0.00.0.0010.0.00.0.000.
Senary0.30.20.130.0.10.0.0430.040.00.0.030.
Decimal0.50.0.250.20.10.0.1250.0.10.0.080.

Sum of the digits in ternary as opposed to binary

The value of a binary number with n bits that are all 1 is.
Similarly, for a number N with base b and d digits, all of which are the maximal digit value, we can write:
Then
For a three-digit ternary number,.

Compact ternary representation: base 9 and 27

Nonary or septemvigesimal can be used for compact representation of ternary, similar to how octal and hexadecimal systems are used in place of binary.

Practical usage

In certain analog logic, the state of the circuit is often expressed ternary. This is most commonly seen in CMOS circuits, and also in transistor–transistor logic with totem-pole output. The output is said to either be low, high, or open. In this configuration the output of the circuit is actually not connected to any voltage reference at all. Where the signal is usually grounded to a certain reference, or at a certain voltage level, the state is said to be high impedance because it is open and serves its own reference. Thus, the actual voltage level is sometimes unpredictable.

A rare "ternary point" in common use is for defensive statics in American baseball, to denote fractional parts of an inning. Since the team on offense is allowed three outs, each out is considered one third of a defensive inning and is denoted as .1. For example, if a player pitched all of the 4th, 5th and 6th innings, plus achieving 2 outs in the 7th inning, his innings pitched column for that game would be listed as 3.2, the equivalent of . In this usage, only the fractional part of the number is written in ternary form.
Ternary numbers can be used to convey self–similar structures like the Sierpinski triangle or the Cantor set conveniently. Additionally, it turns out that the ternary representation is useful for defining the Cantor set and related point sets, because of the way the Cantor set is constructed. The Cantor set consists of the points from 0 to 1 that have a ternary expression that does not contain any instance of the digit 1. Any terminating expansion in the ternary system is equivalent to the expression that is identical up to the term preceding the last non-zero term followed by the term one less than the last nonzero term of the first expression, followed by an infinite tail of twos. For example: 0.1020 is equivalent to 0.1012222... because the expansions are the same until the "two" of the first expression, the two was decremented in the second expansion, and trailing zeros were replaced with trailing twos in the second expression.
Ternary is the integer base with the lowest radix economy, followed closely by binary and quaternary. It has been used for some computing systems because of this efficiency. It is also used to represent three-option trees, such as phone menu systems, which allow a simple path to any branch.
A form of redundant binary representation called a binary signed-digit number system, a form of signed-digit representation, is sometimes used in low-level software and hardware to accomplish fast addition of integers because it can eliminate carries.

Binary-coded ternary

Simulation of ternary computers using binary computers, or interfacing between ternary and binary computers, can involve use of binary-coded ternary numbers, with two bits used to encode each trit. BCT encoding is analogous to binary-coded decimal encoding. If the trit values 0, 1 and 2 are encoded 00, 01 and 10, conversion in either direction between binary-coded ternary and binary can be done in logarithmic time. A library of C code supporting BCT arithmetic is available.

Tryte

Some ternary computers such as the Setun defined a tryte to be six trits or approximately 9.5 bits.