XXIIVV

Ternary numbers are a base 3 numeral system.

Base 10 is famously well suited to those of us who count on our fingers. Base 2 dominates computing technology because binary devices are simple and reliable, with just two stable states on or off. The cultural preference for base 10 and the engineering advantages of base 2 have nothing to do with any intrinsic properties of the decimal and binary numbering systems.

Base 3, on the other hand, does have a genuine mathematical distinction in its favor. By one plausible measure, it is the most efficient of all integer bases; it offers the most economical way of representing numbers as it is closer than binary to the most economical radix base(2.718) to represent arbitrary numbers, when economy is measured as the product of the radix and the number of digits needed to express a given range of values.

Balanced Ternary

UnsignedBalanced
Dec.Tern.Tern.Dec.
000---4
101-0-3
202-+-2
3100--1
411000
5120+1
620+-2
721+03
822++4

The digits of a balanced ternary numeral are coefficients of powers of 3, but instead of coming from the set {0, 1, 2}, the digits are {-, 0 and +}. They are balanced because they are arranged symmetrically about zero.

Arithmetic is nearly as simple as it is with binary numbers; in particular, the multiplication table is trivial. Addition and subtraction are essentially the same operation: Just negate one number and then add. Negation itself is also effortless: Change every -1 into a 1, and vice versa. Rounding is mere truncation: Setting the least-significant trits to 0 automatically rounds to the closest power of 3.

Perhaps the prettiest number system of all is the balanced ternary notation. Donald E. Knuth, The Art of Computer Programming

Ternary Logic

Consider the task of comparing two numbers. In a machine based on binary logic, comparison is often a two-stage process. First you ask, "Is x less than y?"; depending on the answer, you may then have to ask a second question, such as "Is x equal to y?" Ternary logic simplifies the process: A single comparison can yield any of three possible outcomes: "less," "equal" and "greater."

Single Input Gates

Single input ternary logic gates take a single trit, and output a single trit. The gates uses the heptavintimal notation, as well a name to reflect their effect. The reversible logic gates are highlighted, to learn more, see reversible computing.

The table below shows the permutation of every possible balanced ternary input and their equivalent output. For example, if the E gate(negation) gets a bt- input, it will output a bt+.

+0-NumberNameDefinitions
0----13FalseNEG(LAX(LAX))
A--0-12NEG(LAX)
B--+-11Decoder(-)DEC(DEC(LAX))
C-0--10AbnNEG(LAX(DEC))
D-00-9DEC(LAX(NEG))
E-0+-8NegationNEG
F-+--7Decoder(0)DEC(DEC(LAX(DEC)))
G-+0-6IncrementDEC(DEC)
H-++-5DEC(NEG(LAX(NEG)))
I0---4NEG(LAX(NEG))
J0-0-3DEC(LAX(DEC))
K0-+-2DecrementDEC
L00--1DEC(LAX)
M0000ClearDEC(LAX(LAX))
N00+1NEG(DEC(LAX))
O0+-2NEG(DEC)
P0+03NEG(DEC(LAX(DEC)))
Q0++4LAX(NEG)
R+--5Floor/Decoder(+)DEC(DEC(LAX(NEG)))
S+-06DEC(NEG)
T+-+7DEC(NEG(LAX(DEC)))
U+0-8IdentityNEG(NEG)
V+009FlatNEG(DEC(LAX(NEG)))
W+0+10AbsLAX(DEC)
X++-11CeilDEC(NEG(LAX))
Y++012LaxLAX
Z+++13TrueLAX(LAX)

incoming: heptavintimal ternary computing terscii solrela