# Ternary computer

A ternary computer, also called trinary computer, is one that uses ternary logic (i.e., base 3) instead of the more common binary system (i.e., base 2) in its calculations. Ternary computers use trits, instead of binary bits.

## Types of states

Ternary computing deals with three discrete states, but the ternary digits themselves can be defined differently:
| System | States | States | States |
| Unbalanced ternary | 0 | 1 | 2 |
| Fractional unbalanced ternary | 0 | 1⁄2 | 1 |
| Balanced ternary | −1 | 0 | 1 |
| Unknown-state logic | F | ? | T |
| Ternary-coded binary | T | F | T |
Ternary quantum computers use qutrits rather than trits. A qutrit is a quantum state that is a complex unit vector in three dimensions, which can be written as $|\Psi \rangle =\alpha |0\rangle +\beta |1\rangle +\gamma |2\rangle$ in the bra-ket notation. The labels given to the basis vectors ($|0\rangle ,|1\rangle ,|2\rangle$) can be replaced with other labels, for example those given above.

## History

   I often reflect that had the Ternary instead of the denary Notation been adopted in the Infancy of Society, machines something like the present would long ere this have been common, as the transition from mental to mechanical calculation would have been so very obvious and simple.
One early calculating machine, built entirely from wood by Thomas Fowler in 1840, operated in balanced ternary. The first modern, electronic ternary computer, Setun, was built in 1958 in the Soviet Union at the Moscow State University by Nikolay Brusentsov, and it had notable advantages over the binary computers that eventually replaced it, such as lower electricity consumption and lower production cost. In 1970 Brusentsov built an enhanced version of the computer, which he called Setun-70. In the United States, the ternary computing emulator Ternac working on a binary machine was developed in 1973.$^{:22}$
The ternary computer QTC-1 was developed in Canada.

## Balanced ternary

Ternary computing is commonly implemented in terms of balanced ternary, which uses the three digits −1, 0, and +1. The negative value of any balanced ternary digit can be obtained by replacing every + with a − and vice versa. It is easy to subtract a number by inverting the + and − digits and then using normal addition. Balanced ternary can express negative values as easily as positive ones, without the need for a leading negative sign as with unbalanced numbers. These advantages make some calculations more efficient in ternary than binary. Considering that digit signs are mandatory, and nonzero digits are magnitude 1 only, notation that drops the '1's and use only zero and the + − signs is more concise than if 1's are included.

## Unbalanced ternary

Ternary computing can be implemented in terms of unbalanced ternary, which uses the three digits 0, 1, 2. The original 0 and 1 are explained as an ordinary binary computer, but instead uses 2 as leakage current.
The world's first unbalanced ternary semiconductor design on a large wafer was implemented by the research team led by Kim Kyung-rok at Ulsan National Institute of Science and Technology in South Korea, which will help development of low power and high computing microchips in the future. This research theme was selected as one of the future projects funded by Samsung in 2017, published on July 15, 2019.

## Potential future applications

With the advent of mass-produced binary components for computers, ternary computers have diminished in significance. However, Donald Knuth argues that they will be brought back into development in the future to take advantage of ternary logic's elegance and efficiency. One possible way this could happen is by combining an optical computer with the ternary logic system. A ternary computer using fiber optics could use dark as 0 and two orthogonal polarizations of light as +1 and −1.
The Josephson junction has been proposed as a balanced ternary memory cell, using circulating superconducting currents, either clockwise, counterclockwise, or off. "The advantages of the proposed memory circuit are capability of high speed computation, low power consumption and very simple construction with fewer elements due to the ternary operation."
Ternary computing shows promise for implementing fast large language models (LLMs) and potentially other AI applications, in lieu of floating point arithmetic.

## In popular culture

In Robert A. Heinlein's novel Time Enough for Love, the sapient computers of Secundus, the planet on which part of the framing story is set, including Minerva, use an unbalanced ternary system. Minerva, in reporting a calculation result, says "three hundred forty one thousand six hundred forty... the original ternary readout is unit pair pair comma unit nil nil comma unit pair pair comma unit nil nil point nil".

## Modern researches

With the emergence of Carbon nano tube transistors, many researches have shown interest in designing ternary logic gates using them. During 2020–2024 more than 1000 papers about this subject on IEEE Xplore have been published.