It’s usually said that students who would like to study computer science should familiarize themselves with binary representation of numbers and thus get used to very common powers of 2, i.e. 2¹=2, 2²=4, 2³=8, etc. That’s definitely true; the digital world we live in uses bits and almost all programming languages are based on Boolean algebra. But, just because something is popular does not mean it’s good. In this short article, my aim is to give the reader a general understanding of the concept of balanced ternary, the benefits of using it, and finally some history of earlier attempts to create ternary computers.

**Intro**

The concept *Balanced ternary* has many underlying ideas, so let’s try to break it down into things we can relate to. The word *ternary, *in this context, refers to *ternary numeral system*. A *numeral system* is a way different people express numbers: the Great Greeks used a superscript on letters to identify numbers, i.e. **α’, β’, γ’**. In the Roman Empire, they used **I, II, III, IV **(we still use these numbers in names, i.e. Charles **XII**). Many people nowadays use numbers like **0, ****1, 2, 3, 4, 5, 6, 7, 8, 9 **(origin from Hindu-Arabic numbers). This way of writing numbers can be referred to as *base 10 * or simply *decimal*. A ternary numeral base is similar to decimal, but allows only **0, 1, 2**. In binary (base 2), we only allow **0, 1**.

Decimal (Base 10) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

Ternary (Base 3) | 0 | 1 | 2 | 10 | 11 | 12 | 20 | 21 | 22 | 100 | 101 |

A clear observation from this table is that once digits end (i.e. going from 9 to 10), we put a zero and carry a 1 forward (in the number). This is similar to base 3, however, since we only have **0, 1, 2**, our digits end faster than in base 10.

There exists an algorithm to convert between different bases, but that would probably be better suited for another article. Therefore, it’s not going to be discussed here (convert numbers). However, it’s quite simple to convert from base 3 to base 10 by an interesting observation. For example, **123 **is equivalent to saying that **123= ****1*10²+2*10¹+3*10⁰ = 1*100+2*10+3**. In base 3, we have a similar approach, but instead of **10**, we use **3**. Say we want to convert **22 **(in base 3) to base 10. Therefore, **2*****3¹+2*3⁰=2*3+2=8 **(in base 10). This conclusion goes hand in hand with the one in the table.

Now, we should have some grasp of *ternary numeral systems*. Let’s move on to the term *balanced*. A intuitive way of thinking about it that something should be balanced, like masses on opposite sides of a weight should cancel out. So, how would such system look like? I turns out that instead of saying that we can use digits **0, 1, 2** we instead introduce **-1** so that the digits in the balanced ternary system are **-1**,** 0, 1** (looks to be balanced?). Let’s refer to the **-1** as **n** and **1** as **p**. The table below links the numbers in base 10 with the ones in balanced ternary.

Decimal (Base 10) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

Balanced Ternary (Base 3) | 0 | p | pn | p0 | pp | pnn | pn0 | pnp | p0n | p00 | p0p |

There is a similar pattern here as for unbalanced ternary. The interested reader should consider to experiment with this concept by implementing it in the favourite programming language (see all implementations).

**Benefits**

Here are some of the benefits of the balanced ternary:

- The sign (
**+/-**) is stored in the number, and can be deduced by the leading trit (similar to bit). So, if a number starts with**-1**, or using our notation,**n**, we know it’s negative. - In order to get the number with the opposite sign, simply replace all
**n**‘s with**p**‘s and all**p**‘s with**n**‘s. Eg. Since 7 is**pnp**, -7 is**npn**. - In order to round to the nearest integer, the fractional part should be removed.
- Things don’t have to be either
**true**or**false**. There exists an**unknown**case also.

**History**

It might seem that this idea works in theory but not in real computers. However, this is not true. At Moscow State University, a series of Setun computers was developed. The first Setun was built in 1958. An interesting thing that can be noted is that it used ternary logic.

**Further reading**

For those who are interested, please take a look at the links below:

- http://www.computer-museum.ru/english/setun.htm
- http://en.wikipedia.org/wiki/Heyting_algebra
- http://tunguska.sourceforge.net/The_Fine_Manual.pdf

**Edits:**

- Corrected the base10-base3 table.
- First published 20.12.2014 (dd/mm/yyyy)

## Leave a Reply