{{Short description|Computer that uses ternary logic}} {{more citations needed|date=December 2014}}

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:<ref>{{cite web|url= http://xyzzy.freeshell.org/trinary/CPE%20Report%20-%20Ternary%20Computing%20Testbed%20-%20RC6a.pdf |title=Ternary Computing Testbed 3-Trit Computer Architecture|year=2008|first=Jeff |last=Connelly |publisher=California Polytechnic State University of San Luis Obispo}}</ref>

{| class="wikitable" ! System ! colspan=3 | States |- | Unbalanced ternary | align=center | 0 || align=center | 1 || align=center | 2 |- | Fractional unbalanced ternary | align=center | 0 || align=center | {{sfrac|1|2}} || align=center | 1 |- | Balanced ternary | align=center | −1 || align=center | 0 || align=center | 1 |- | Unknown-state logic | align=center | F || align=center |? || align="center" | T |- | Ternary-coded binary | align=center | T || align=center | F || align=center | T |}

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.<ref name=AoCP2/> Considering that digit signs are mandatory, and nonzero digits are magnitude 1 only, notation that drops the 1s and use only 0 and the + and − signs is more concise than if 1s are included.

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.<ref>{{cite news |url=https://www.mk.co.kr/news/english/view/2019/07/533039/ |title=S. Korean researchers develop world's first ternary semiconductor tech |newspaper=Maeil Business Newspaper |date=17 July 2019 }}</ref>

== History == {{blockquote |text = 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. |sign = Thomas Fowler|source=letter to Sir George Biddell Airy<ref name="bedroom-theory"/> }}

One early calculating machine, built entirely from wood by Thomas Fowler in 1840, operated in balanced ternary.<ref name="tf1">{{cite web |url=http://myweb.tiscali.co.uk/torrington/fowler.htm |first1=John |last1=McKay |first2=Pamela |last2=Vass |title=Thomas Fowler |archiveurl=https://web.archive.org/web/20070531221517/http://myweb.tiscali.co.uk/torrington/fowler.htm |archivedate=31 May 2007|url-status=dead}}</ref><ref name="tf2">{{cite journal |first1=Mark |last1=Glusker |first2=David M. |last2=Hogan |first3=Pamela |last3=Vass |title=The Ternary Calculating Machine of Thomas Fowler |journal=IEEE Annals of the History of Computing |volume=27 |number=3 |pages=4–22 |date=July–September 2005 |doi=10.1109/mahc.2005.49 }}</ref><ref name="bedroom-theory">{{cite book |last=Hayes |first=Brian |url=https://books.google.com/books?id=1ZkYEFi3DMMC&q=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.&pg=PA196 |title=Group Theory in the Bedroom, and Other Mathematical Diversions |date=2008-04-01 |publisher=Farrar, Straus and Giroux |isbn=978-1-4299-3857-0 |language=en }}</ref>

The first modern, electronic ternary computer, Setun, was built in 1958 in the Soviet Union at the Moscow State University by Nikolay Brusentsov,<ref name="cmr">{{cite web | url=http://www.computer-museum.ru/english/galglory_en/Brusentsov.htm | work=Russian Virtual Computer Museum: Hall of Fame | title=Nikolay Petrovich Brusentsov | first=Alexander |last=Nitusov |accessdate=25 January 2010 }}</ref><ref>{{cite book | last1 = Trogemann | first1 = Georg | last2 = Nitussov | first2 = Alexander Y. | last3 = Ernst | first3 = Wolfgang | isbn = 978-3-528-05757-2 | pages = 19, 55, 57, 91, 104–107 | publisher = Vieweg+Teubner Verlag | title = Computing in Russia: the history of computer devices and information technology revealed | year = 2001 }}.</ref> and it had notable advantages over the binary computers that eventually replaced it, such as lower electricity consumption and lower production cost.{{citation needed|date=July 2023}} In 1970 Brusentsov built an enhanced version of the computer, which he called Setun-70.<ref name="cmr" />

In the United States, the ternary computing emulator Ternac working on a binary machine was developed in 1973.<ref name="comp1974">{{cite journal | title=The development of multiple-valued logic as related to computer science | author1-first=George | author1-last=Epstein | author2-first=Gideon | author2-last=Frieder | author3-first=David C. | author3-last=Rine | journal=Computer | year=1974 | pages=20–32 | volume=7 | issue=9 | issn=0018-9162 | eissn=1558-0814 | publisher=IEEE | doi=10.1109/MC.1974.6323304 |s2cid=30527807 }}</ref>{{rp|22}} The ternary computer QTC-1 was developed in Canada.<ref>{{cite conference |first1=Y. H. |last1=Cho |first2=H. T. |last2=Mouftah |date=1988 |url=https://wwwee.ee.bgu.ac.il/~kushnero/ternary/Using%20CMOS%20gates/A%20CMOS%20ternary%20ROM%20chip.pdf |title=A CMOS ternary ROM chip |work=Proceedings. The Eighteenth International Symposium on Multiple-Valued Logic |pages=358–363 |publisher=IEEE |doi=10.1109/ISMVL.1988.5195 |isbn=0-8186-0859-5 |archive-url=https://web.archive.org/web/20240203092056/https://wwwee.ee.bgu.ac.il/~kushnero/ternary/Using%20CMOS%20gates/A%20CMOS%20ternary%20ROM%20chip.pdf |archive-date=2024-02-03 }}</ref>

== Future applications and research ==

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.<ref name="AoCP2">{{cite book |last=Knuth |first=Donald |title=The Art of Computer Programming |volume=2: Seminumerical Algorithms |pages=190–192 |publisher=Addison-Wesley |edition=2nd |date=1980 |isbn=0-201-03822-6 |title-link=The Art of Computer Programming }}.</ref> One possible way this could happen is by combining an optical computer with the ternary logic system.<ref>{{cite journal |title=Ternary Optical Computer Architecture |author1=Jin Yi |author2=He Huacan |author3=Lü Yangtian |year=2005 |doi=10.1238/Physica.Topical.118a00098 |volume=T118 |pages=98–101 |journal=Physica Scripta |bibcode=2005PhST..118...98Y |doi-access=free }}</ref> A ternary computer using fiber optics could use dark as 0 and two orthogonal polarizations of light as +1 and −1.<ref>{{Cite journal |last=Jin |first=Yi |date=2003 |title=Ternary optical computer principle |url=https://link.springer.com/article/10.1360/03yf9012 |journal=Science in China Series F: Information Sciences |language=en |volume=46 |issue=2 |pages=145–150 |doi=10.1360/03yf9012 |doi-broken-date=1 July 2025 |s2cid=35306726 |issn=1009-2757|url-access=subscription }}</ref>

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."<ref>{{cite book | doi = 10.1109/ISMVL.1998.679270 | pages=19–24 | year=1998 | last1=Morisue | first1=M. | last2=Endo | first2=J. | last3=Morooka | first3=T. | last4=Shimizu | first4=N. | last5=Sakamoto | first5=M. | title=Proceedings. 1998 28th IEEE International Symposium on Multiple- Valued Logic (Cat. No.98CB36138) | chapter=A Josephson ternary memory circuit | isbn=978-0-8186-8371-8 | s2cid=19998395 }}</ref>

Ternary computing shows promise for implementing fast ternary large language models (LLMs) and potentially other AI applications, in lieu of floating point arithmetic.<ref>{{cite journal |title=The Era of 1-bit LLMs: All Large Language Models are in 1.58 Bits |arxiv=2402.17764 |journal=Computation and Language |date=27 Feb 2024 |last1=Ma |first1=Shuming |last2=Wang |first2=Hongyu |last3=Ma |first3=Lingxiao |last4=Wang |first4=Lei |last5=Wang |first5=Wenhui |last6=Huang |first6=Shaohan |last7=Dong |first7=Li |last8=Wang |first8=Ruiping |last9=Xue |first9=Jilong |last10=Wei |first10=Furu }}</ref>

With the emergence of carbon nanotube transistors, many research projects have shown interest in designing ternary logic gates using them. Between 2020 and 2024, more than 100 papers about this subject were published on IEEE Xplore.<ref>{{cite web |title=IEEE Xplore Search Results |url=https://ieeexplore.ieee.org/search/searchresult.jsp?action=search&newsearch=true&matchBoolean=true&queryText=(%22All%20Metadata%22:ternary)%20AND%20((%22All%20Metadata%22:CNFET)%20OR%20(%22All%20Metadata%22:CNTFET)) |url-status=live |archive-url=https://web.archive.org/web/20240617145335/https://ieeexplore.ieee.org/search/searchresult.jsp?action=search&newsearch=true&matchBoolean=true&queryText=(%22All%20Metadata%22:ternary)%20AND%20((%22All%20Metadata%22:CNFET)%20OR%20(%22All%20Metadata%22:CNTFET)) |archive-date=2024-06-17 |access-date=2024-06-17 |website=IEEE Xplore |agency=IEEE}}</ref>

In 2025, a patent by Huawei proposed a ternary logic gate able to add and subtract ternary inputs. It is introduced as a "ternary logic gate circuit, a computing circuit, a chip, and an electronic device". It uses three transistors with three different voltage level (low, medium and high) to build ternary logic gates.<ref>{{Cite patent|number=CN119652311A|title=Ternary logic gate circuit, computing circuit, chip and electronic device|gdate=2025-03-18|invent1=胡海林|invent2=黄明强|invent3=赵广超|invent4=李文硕|url=https://patents.google.com/patent/CN119652311A/en}}</ref>

== Quantum ternary ==

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 <math>|\Psi\rangle = \alpha|0\rangle + \beta|1\rangle + \gamma|2\rangle</math> in the bra–ket notation.<ref>{{cite book |author=Colin P. Williams |year=2011 |title=Explorations in Quantum Computing |publisher=Springer |isbn=978-1-84628-887-6 |pages=22–23 }}</ref> The labels given to the basis vectors ({{tmath| \vert 0 \rangle, \vert 1 \rangle, \vert 2 \rangle }}) can be replaced with other labels, for example those given above.

== 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".<ref>{{cite book|last=Heinlein |first=Robert |author-link=Robert A. Heinlein |year=1982 |chapter=Variations on a theme&nbsp;III: Domestic problems |title=Time Enough for Love |publisher=Berkley Books |page=99 |isbn=978-0-399-11151-8 |title-link=Time Enough for Love }}</ref>

== See also ==

* {{annotated link|Decimal computer}} * {{annotated link|Flip-flop (electronics)}} * {{annotated link|Radix economy}} * {{annotated link|Skew binary number system}} * {{annotated link|Ternary numeral system}} * {{annotated link|Ternary signal}} * {{annotated link|Unconventional computing}}

== References ==

{{reflist}}

== Further reading ==

* {{cite book |last= Hunger |first= Francis |title= Eine Recherche über den sowjetischen Ternarcomputer |trans-title= SETUN. An Inquiry into the Soviet Ternary Computer |publisher= Institut für Buchkunst Leipzig |date= 2007 |isbn= 978-3-932865-48-0 |language= en }}

== External links ==

* [http://www.mortati.com/glusker/fowler/ The ternary calculating machine of Thomas Fowler] * [http://www.computer-museum.ru/english/setun.htm Development of ternary computers at Moscow State University] * [https://tunguska.sourceforge.net/about.html Tunguska – Ternary Operating System emulator] * [https://hackaday.io/project/28579-homebrew-ternary-computer Triador: a ternary computer with 600 ternary multiplexers] * [https://www.ternary-computing.com/ 5500FP - modern ternary CPU]

Category:Classes of computers Category:Ternary computers