A ternary numeral system (also called base 3 or trinary) has three as its base. A ternary digit is a trit (trinary digit), analogously to a bit. One trit is equivalent to log<sub>2</sub> 3 (about 1.58496) bits of information.
Although ternary most often refers to a system in which the three digits are all non–negative numbers; specifically , , and , the adjective also lends its name to the balanced ternary system; comprising the digits −1, 0 and +1, used in comparison logic and ternary computers.
Comparison to other bases
Representations of integer numbers in ternary do not get uncomfortably lengthy as quickly as in binary. For example, decimal 365 or senary corresponds to binary (nine bits) and to ternary (six trits). However, they are still far less compact than the corresponding representations in bases such as decimal – see below for a compact way to codify ternary using nonary (base 9) and septemvigesimal (base 27).
{| class="wikitable" style="float:right; text-align:center"
|+ A ternary multiplication table
|-
! × || 1|| 2 || 10 || 11 || 12 || 20 || 21 || 22 || 100
|-
! 1
| 1 || 2 || 10 || 11 || 12 || 20 || 21 || 22 || 100
|-
! 2
| 2 || 11 || 20 || 22 || 101 || 110 || 112 || 121 || 200
|-
! 10
| 10 || 20 || 100 || 110 || 120 || 200 || 210 || 220 ||
|-
! 11
| 11 || 22 || 110 || 121 || 202 || 220 || || ||
|-
! 12
| 12 || 101 || 120 || 202 || 221 ||
| || ||
|-
! 20
| 20 || 110 || 200 || 220 || ||
| || ||
|-
! 21
| 21 || 112 || 210 || || ||
| || ||
|-
! 22
| 22 || 121 || 220 || || ||
| || ||
|-
! 100
| 100 || 200 || || || ||
| || ||
|}
: {| class="wikitable"
|+ Numbers from 0 to 3<sup>3</sup> − 1 in standard ternary
|- align="center"
! Ternary
| 0 || 1 || 2 || 10 || 11 || 12 || 20 || 21 || 22
|- align="center"
! Binary
| 0 || 1 || 10 || 11 || 100 || 101 || 110 || 111 || 1000
|- align="center"
! Senary
| 0 || 1 || 2 || 3 || 4 || 5 || 10 || 11 || 12
|- align="center"
! Decimal
! 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8
|-
|colspan=10 style="background-color:white;"|
|- align="center"
! Ternary
| 100 || 101 || 102 || 110 || 111 || 112 || 120 || 121 || 122
|- align="center"
! Binary
| 1001 || 1010 || 1011 || 1100 || 1101 || 1110 || 1111
| ||
|- align="center"
! Senary
| 13 || 14 || 15 || 20 || 21 || 22 || 23 || 24 || 25
|- align="center"
! Decimal
! 9 ||10 || 11 || 12|| 13 || 14 || 15 || 16 || 17
|-
|colspan=10 style="background-color:white;"|
|- align="center"
! Ternary
| 200 || 201 || 202 || 210 || 211 || 212 || 220 || 221 || 222
|- align="center"
! Binary
| || || || ||
| || || ||
|- align="center"
! Senary
| 30 || 31 || 32 || 33 || 34 || 35 || 40 || 41 || 42
|- align="center"
! Decimal
! 18 || 19 || 20 || 21 || 22 || 23 || 24 || 25 || 26
|}
:
: {| class="wikitable"
|+ Powers of 3 in ternary
|- align="center"
! Ternary
| 1 || 10 || 100 || ||
|- align="center"
! Binary
| 1 || 11 || 1001 || ||
|- align="center"
! Senary
| 1 || 3 || 13 || 43 || 213
|- align="center"
! Decimal
| 1 || 3 || 9 || 27 || 81
|- align="center"
! Power
! || ||
! ||
|-
|colspan=10 style="background-color:white;"|
|- align="center"
! Ternary
| || ||
| ||
|- align="center"
! Binary
| || ||
| ||
|- align="center"
! Senary
| || || || ||
|- align="center"
! Decimal
| 243 || 729 || || ||
|- align="center"
! Power
! || ||
! ||
|}
As for rational numbers, ternary offers a convenient way to represent as same as senary (as opposed to its cumbersome representation as an infinite string of recurring digits in decimal); but a major drawback is that, in turn, ternary does not offer a finite representation for (nor for , , etc.), because 2 has a prime factor that is not a factor of the base; as with base two, one-tenth (decimal , senary ) is not representable exactly (that would need e.g. decimal); nor is one-sixth (senary , decimal ).
: {| class="wikitable"
|+ Fractions in ternary
|- align="center"
! Fraction
| || || || || || || || || || || ||
|- align="center"
! Ternary
| 0. || 0.1 || 0. || 0. || 0.0 || 0. || 0. || 0.01 || 0. || 0. || 0.0 || 0.
|- align="center"
! Binary
| 0.1 || 0. || 0.01 || 0. || 0.0 || 0. || 0.001 || 0. || 0.0 || 0. || 0.00 || 0.
|- align="center"
! Senary
| 0.3 || 0.2 || 0.13 || 0. || 0.1 || 0. || 0.043 || 0.04 || 0.0 || 0. || 0.03 || 0.
|- align="center"
! Decimal
! 0.5 || 0. || 0.25 || 0.2 || 0.1 || 0. || 0.125
! 0. || 0.1 || 0. || 0.08 || 0.
|}
Sum of the digits in ternary as opposed to binary
The value of a binary number with bits that are all 1 is .
Similarly, for a number N(b, d) with base b and d digits, all of which are the maximal digit value , we can write:
:
:
: .
: and
: , so
: , or
:
Then
:
:
:
For a three-digit ternary number, .
Compact ternary representation: base 9 and 27
{| class="wikitable" style="float:right; text-align:center"
|+ Comparison between ternary and nonary
|-
! ternary || nonary
|-
| 00 || 0
|-
| 01 || 1
|-
| 02 || 2
|-
| 10 || 3
|-
| 11 || 4
|-
| 12 || 5
|-
| 20 || 6
|-
| 21 || 7
|-
| 22 || 8
|}
Nonary (base 9, each digit is two ternary digits) or septemvigesimal (base 27, each digit is three ternary digits) can be used for compact representation of ternary, similar to how octal and hexadecimal systems are used in place of binary.
Practical use
thumb|Use of ternary numbers to balance an unknown integer weight from 1 to 40 kg with weights of 1, 3, 9 and 27 kg (4 ternary digits actually gives 3<sup>4</sup> = 81 possible combinations: −40 to +40, but only the positive values are useful)
In certain analog logic, the state of the circuit is often expressed ternary. This is most commonly seen in CMOS circuits, and also in transistor–transistor logic with totem-pole output. The output is said to either be low (grounded), high, or open (high-Z). In this configuration the output of the circuit is actually not connected to any voltage reference at all. Where the signal is usually grounded to a certain reference, or at a certain voltage level, the state is said to be high impedance because it is open and serves its own reference. Thus, the actual voltage level is sometimes unpredictable.
A rare "ternary point" in common use is for defensive statistics in American baseball (usually just for pitchers), to denote fractional parts of an inning. Since the team on offense is allowed three outs, each out is considered one third of a defensive inning and is denoted as .1. For example, if a player pitched all of the 4th, 5th and 6th innings, plus achieving 2 outs in the 7th inning, his innings pitched column for that game would be listed as 3.2, the equivalent of (which is sometimes used as an alternative by some record keepers). In this usage, only the fractional part of the number is written in ternary form.
Ternary numbers can be used to convey self-similar structures like the Sierpinski triangle or the Cantor set conveniently. Additionally, it turns out that the ternary representation is useful for defining the Cantor set and related point sets, because of the way the Cantor set is constructed. The Cantor set consists of the points from 0 to 1 that have a ternary expression that does not contain any instance of the digit 1.
</references>
Further reading
External links
- Ternary Arithmetic
- The ternary calculating machine of Thomas Fowler
- Ternary Base Conversionincludes fractional part, from Maths Is Fun
- Gideon Frieder's replacement ternary numeral system
- Visualization of ternary numeral system
