A classic "Futurama" episode has robot Bender waking from a nightmare: “Ahhh, what an awful dream. Ones and zeros everywhere… [shudder] and I thought I saw a two!”
His friend Fry: comforts him. “It was just a dream, Bender. There’s no such thing as two.”
Anyone familiar with digital computing knows about zeros and ones — including characters in the “Futurama” cartoon. Zeros and ones are the building blocks of binary language. But not all computers are digital, and nothing says that digital computers have to be binary. What if we used a base-3 system instead of base-2? Could a computer conceive of a third digit?
As computer science essayist Brian Hayes noted, “People count by tens and machines count by twos.” A few brave souls have dared to consider a ternary alternative. Louis Howell proposed the programming language TriINTERCAL using the base-3 numbering system in 1991. And Russian innovators built a few dozen base-3 machines over 50 years ago. But the numbering system didn’t catch on in the broader computer world.
A ternary computer (also called a trinary computer) is a computer that uses ternary logic (three possible values) instead of the more common binary logic (two possible values) in its calculations.
Ternary computing has many basic benefits over binary computing. These include:
- Higher data throughput.
- Access to additional instructions.
- Back-compatibility with legacy binary codes.
- Preventing malware and viruses.
However, the usual purpose of ternary computers has not been met with overwhelming success so far, because they are not as efficient as the binary ones to compute binary codes, which is generally preferred and seems almost omnipresent.
Ternary Logic
Given the limited space here, we’ll just touch on a few mathematical ideas to give us some background. For a more in-depth understanding of the subject, have a look at Hayes’ excellent article “Third Base” in the Nov/Dec 2001 issue of American Scientist.
The word “ternary” relates to the number three. Generally, something that is ternary is composed of three parts or divisions. A ternary form in music is a song form made up of three sections. In mathematics, ternary means using three as a base. Some people prefer the word trinary, perhaps because it rhymes with binary.
Jeff Connelly covers a few more terms in his 2008 paper “Ternary Computing Testbed 3-Trit Computer Architecture.” A “trit” is the ternary equivalent of a bit. If a bit is a binary digit that can have one of two values, then a trit is a ternary digit that can have any of three values. A trit is one base-3 digit. A “tryte” would be 6 trits. Connelly (and perhaps no one else) defines a “tribble” as half a trit (or one base-27 digit) and he calls one base-9 digit a “nit.” (For more on data measurement, see Understanding Bits, Bytes and Their Multiples.)
It can all become a bit overwhelming,, so we’ll just look at another concept to help us get a grasp of the numbers. Ternary computing deals with three discrete states, but the ternary digits themselves can be defined in different ways, according to Connelly:
- Unbalanced Trinary — {0, 1, 2}
- Fractional Unbalanced Trinary — {0, 1/2, 1}
- Balanced Trinary — {-1, 0, 1}
- Unknown-State Logic — {F, ?, T}
- Trinary Coded Binary — {T, F, T}
Balanced ternary
Ternary computing is very much applied in terms of balanced ternary, which uses the three digits −1, 0, and +1. The negative value of any balanced ternary digit can be gained by replacing every + with a − and vice versa. It is easy to subtract a number by inverting the + and − digits and then applying the normal addition function. Balanced ternary can state negative values as easily as positive ones, without the need for a leading negative sign as with unbalanced numbers.
Unbalanced ternary
Ternary computing can be applied in terms of unbalanced ternary, which uses the three digits 0, 1, 2. The original 0 and 1 are described as an ordinary Binary computer but instead, it uses 2 as leakage current.
Ternary Computers in History
There’s not much to cover here because, as Connelly put it, “Trinary technology is relatively unexplored territory in the computer architecture field.” While there may be a hidden treasure of university research on the subject, not many base-3 computers have made it into production. At the 2016 Hackaday Superconference, Jessica Tank gave a talk on the ternary computer that she’s been working on for the past few years. Whether her efforts will rise from obscurity remains to be seen.
The original ternary computer was an early calculating machine, created by Thomas Fowler from wood in 1840 that operated in balanced ternary. The first modern ternary computer Setun was built in 1958 in the Soviet Union by Nikolay Brusentsov. Working with the notable Soviet mathematician Sergei Lvovich Sobolev, Brusentsov created a research team at Moscow State University and designed a ternary computer architecture that would result in the construction of 50 machines.
As researcher Earl T. Campbell states on his website, SETUN “was always a university project, not fully endorsed by the Soviet government, and viewed suspiciously by factory management.”
In1970 Brusentsov made an improved version of the computer, which he called Setun-70. In the USA, the ternary computing trend also started in the ’50s, where noticeable progress happened in the development of ternary arithmetic, and microelectronic components for ternary computers. Despite having remarkable benefits over the binary versions, binary computers eventually replaced these ternary versions, because of lower electricity consumption and production cost.
Ternary Computer Advantages
SETUN used balanced ternary logic, {-1, 0, 1} as noted above. That’s the common approach to ternary, and it’s also found in the work of Jeff Connelly and Jessica Tank. “Perhaps the prettiest number system of all is the balanced ternary notation,” writes Donald Knuth in an excerpt from his book “The Art of Computer Programming.”
Brian Hayes is also a big fan of ternary. “Here I want to offer three cheers for base 3, the ternary system. … They are the Goldilocks choice among numbering systems: When base 2 is too small and base 10 is too big, base 3 is just right.”
One of Hayes’ arguments for the virtues of base-3 is that it is the closest numbering system to base-e, “the base of the natural logarithms, with a numerical value of about 2.718.” With mathematical prowess, the essayist Hayes explains how base-e (if it were practical) would be the most economical numbering system. It is ubiquitous in nature. And I clearly remember these words from Mr. Robertson, my high school chemistry teacher: “God counts by e.”
The greater efficiency of ternary in comparison to binary can be illustrated by the use of the SETUN computer. Hayes writes: “Setun operated on numbers composed of 18 ternary digits, or trits, giving the machine a numerical range of 387,420,489. A binary computer would need 29 bits to reach this capacity ….”
Why Are Computers Not Ternary?
The Soviet Union actually experimented many times with some ternary computers, but they were never commercialized so far. A ternary bit is known as a trit. The reason we can’t use ternary logic comes down to the way transistors are stacked in a computer—something called “gates”—and how they’re used to carry out math. Gates take two inputs, execute a task on them, and then return one output.
Now we return to the original question of the article. If ternary computing is so much more efficient, why aren’t we all using them? One answer is that things just didn’t happen that way. We have come so far in binary digital computing that it would be pretty hard to turn back. Just as the robot Bender has no idea how to count beyond zero and one, today’s computers operate on a logic system that’s different from what any potential ternary computer would use. Of course, Bender could somehow be made to understand ternary — but it would probably be more like a simulation than a redesign.
And SETUN itself did not realize the greater efficiency of ternary, according to Hayes. He says that because each trit was stored in a pair of magnetic cores “the ternary advantage was squandered.” It seems that the implementation is just as important as the theory.
An extended quote from Hayes seems appropriate here:
Why did base 3 fail to catch on? One easy guess is that reliable three-state devices just didn’t exist or were too hard to develop. And once binary technology became established, the tremendous investment in methods for fabricating binary chips would have overwhelmed any small theoretical advantage of other bases."
Additionally , we must look at hardware peripherals and the laws of physics when it comes to the use of binary. Every number in your computer is an electrical signal. In the previous days of computing, electrical signals were much harder to measure and control in a proper manner. It is more sensible to differentiate between an “on” status—defined by negative charge—and an “off” status—defined by a positive charge. Here “off” is defined by a positive charge because electrons have a negative charge—so more electrons mean more current with a negative charge.
Importantly, this only allows current to flow from the source to the destination when there is a current in the gate. This forms a binary switch. Manufacturers can make these transistors very much small—even around 5 nanometers. This is how modern CPUs function.
Quaternary Computers: the Numbering System of the Future
We’ve talked about bits and trits, but have you heard of qubits? That’s the proposed unit of measurement for quantum computing. The math gets a little fuzzy here. A quantum bit, or qubit, is the smallest unit of quantum information. A qubit can exist in multiple states at once. So while it can represent more than just the two states of binary, it isn’t quite the same as ternary. (To learn more about quantum computing, see Why Quantum Computing May Be the Next Turn on the Big Data Highway.)
And you thought binary and ternary were hard! Quantum physics is not intuitively obvious. The Austrian physicist Erwin Schrödinger offered a thought experiment, famously known as Schrödinger’s cat. You are asked to suppose for a minute a scenario where the cat is both alive and dead simultaneously.
This is where some people get off the bus. It’s ridiculous to propose that a cat could be both alive and dead, but that’s the essence of quantum superposition. The crux of quantum mechanics is that objects have characteristics of both waves and particles. Computer scientists are working to take advantage of these properties.
The superposition of qubits opens a new world of possibilities. Quantum computers are expected to be exponentially faster than binary or ternary computers. The parallelism of multiple qubit states could make a quantum computer millions of times faster than today’s PC.
Conclusion
Until the day the quantum computing revolution changes everything, the status quo of binary computing will remain. When Jessica Tank was asked what use cases might arise for ternary computing, the audience groaned upon hearing a reference to “the internet of things.” And that may be the crux of the matter. Unless the computing community agrees on a very good reason to upset the apple cart and asks their computers to count in threes instead of twos, robots like Bender will continue to think and dream in binary. Meanwhile, the age of quantum computing is just beyond the horizon.