CIT 591 Balanced Ternary

Fall 2010, David Matuszek

Balanced ternary is an unusual, but mathematically quite beautiful, number system. It has the characteristic that all numbers can be represented in a uniform notation; you don't need a minus sign to indicate that "this number is negative." If you enjoy playing around with numbers, you will probably like it.

The decimal number system uses ten digits, `0`

through `9`

,
and a system in which each position in a number is worth ten times the value of
the position to its immediate right. Thus, for example, the number `7204`

indicates "seven thousands, two hundreds, no tens, and four":

10^{3} = 1000 |
10^{2} = 100 |
10^{1} = 10 |
10^{0} = 1 |
---|---|---|---|

`7` (times 10^{3} is 7000) |
`2` (times 10^{2} is 200) |
`0` (times 10^{1} is 0) |
`4` (times 10^{0} is 4) |

`7` *10^{3} + `2` *10^{2} + `0` *10^{1}
+ `4` *10^{0} = `7204` |

Similarly, the ternary system uses three digits,

`0`

, `1`

,
and `2`

, and a system in which each position in a number is worth In a *balanced* ternary system, the
three digits have the values `0`

, `1`

, and `-1`

. To avoid
the awkwardness of using two characters, `'-'`

and `1`

, to represent a
single digit, we will instead use `N`

to stand for the digit `-1`

.
Similar to the above example, then, the number `10N1`

indicates "one `27`

, no `9`

s,
negative one `3`

s, and one` 1`

:

3^{3} = 27 |
3^{2} = 9 |
3^{1} = 3 |
3^{0} = 1 |
---|---|---|---|

`1` (times 3^{3} is 27) |
`0` (times 3^{2} is 0) |
`N` (times 3^{1} is 0) |
`1` (times 3^{0} is 1) |

`1` *3^{3} + `0` *3^{2} + `(-1)` *3^{1}
+ `1` *3^{0} = `10N1` (or, in decimal,
27 + 0 - 3 + 1 = 25) |

In balanced ternary, as in more familiar number systems, there is exactly one way to represent any (integer) number. Unlike familiar number systems, there is no need for an additional symbol to indicate that a number is negative; for example,

`-5`

is represented as
`N11`

Here are some more examples:

Balanced ternary | `N00` |
`N01` |
`N1N` |
`N10` |
`N11` |
`NN` |
`N0` |
`N1` |
`N` |
`0` |
`1` |
`1N` |
`10` |
`11` |
`1NN` |
`1N0` |
`1N1` |
`10N` |
`100` |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|

Decimal equivalent | `-9` |
`-8` |
`-7` |
`-6` |
`-5` |
`-4` |
`-3` |
`-2` |
`-1` |
`0` |
`1` |
`2` |
`3` |
`4` |
`5` |
`6` |
`7` |
`8` |
`9` |

The balanced ternary system can easily be extended to real numbers, for example, `N01.1NN`

. However, we will just use integers.

There is a good, more detailed article on balanced ternary numbers in Wikipedia.