ArticleslgStudy

computer science

Balanced ternary

Balanced ternary is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Balanced ternary rather than just read about it. In short: Balanced ternary is a ternary numeral system (i.e. base 3 with three digits) that uses a balanced signed-digit representation of the integers in which the digits have the values −1, 0, and 1. This stands in contrast to the standard (unbalanced) ternary system, in which digits have values 0, 1 and 2.

Balanced ternary — main illustration
Balanced ternary — illustration

Key takeaways

  • Balanced ternary belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Balanced ternary to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Balanced ternary from memory before moving on to harder problems.

Reference excerpt

Balanced ternary is a ternary numeral system (i.e. base 3 with three digits) that uses a balanced signed-digit representation of the integers in which the digits have the values −1, 0, and 1. This stands in contrast to the standard (unbalanced) ternary system, in which digits have values 0, 1 and 2. The balanced ternary system can represent all integers without using a separate minus sign; the value of the leading non-zero digit of a number has the sign of the number itself. The balanced ternary system is an example of a non-standard positional numeral system. It was used in some early computers and has also been used to solve balance puzzles. Different sources use different glyphs to represent the three digits in balanced ternary. In this article, T (which resembles a ligature of the minus sign and 1) represents −1, while 0 and 1 represent themselves. Other conventions include using '−' and '+' to represent −1 and 1 respectively, or using Greek letter theta (Θ), which resembles a minus sign in a circle, to represent −1. In publications about the Setun computer, −1 is represented as overturned 1: "1". Balanced ternary makes an early appearance in Michael Stifel's book Arithmetica Integra (1544). It also occurs in the works of Johannes Kepler and Léon Lalanne. Related signed-digit schemes in other bases have been discussed by John Colson, John Leslie, Augustin-Louis Cauchy, and possibly even the ancient Indian Vedas.

Definition

Let 𝒟3:={T⁡,0,1} denote the set of symbols (also called glyphs or characters), where the symbol 1¯ is sometimes used in place of T⁡. Define an integer-valued function f=f𝒟3:𝒟3→ℤ by

f(T⁡)=−1,f(0)=0,f(1)=1, where the right hand sides are integers with their usual values. This function, f, is what rigorously and formally establishes how integer values are assigned to the symbols/glyphs in 𝒟3. One benefit of this formalism is that the definition of "the integers" (however they may be defined) is not conflated with any particular system for writing/representing them; in this way, these two distinct (albeit closely related) concepts are kept separate. The set 𝒟3 together with the function f forms a balanced signed-digit representation called the balanced ternary system. It can be used to represent integers and real numbers.

Ternary integer evaluation Let 𝒟3+ be the Kleene plus of 𝒟3, which is the set of all finite length concatenated strings dn…d0 of one or more symbols (called its digits) where n is a non-negative integer and all n+1 digits dn,…,d0 are taken from 𝒟3={T⁡,0,1}. The start of dn…d0 is the symbol d0 (at the right), its end is dn (at the left), and its length is n+1. The ternary evaluation is the function v=v3 : 𝒟3+→ℤ defined by assigning to every string dn…d0∈𝒟3+ the integer

v(dn…d0) = ∑i=0nf(di)3i. The string dn…d0 represents (with respect to v) the integer v(dn…d0). The value v(dn…d0) may alternatively be denoted by dn…d0bal⁡3. The map v:𝒟3+→ℤ is surjective but not injective since, for example, 0=v(0)=v(00)=v(000)=⋯. However, every nonzero integer has exactly one representation under v that does not end (on the left) with the symbol 0, i.e. dn=0. If dn…d0∈𝒟3+ and n>0 then v satisfies:

v(dndn−1…d0) = f(dn)3n+v(dn−1…d0) which shows that v satisfies a sort of recurrence relation. This recurrence relation has the initial condition v(ε)=0 where ε is the empty string. This implies that for every string dn…d0∈𝒟3+,

v(0dn…d0)=v(dn…d0) which in words says that leading 0 symbols (to the left in a string with 2 or more symbols) do not affect the resulting value. The following examples illustrate how some values of v can be computed, where (as before) all integer are written in decimal (base 10) and all elements of 𝒟3+ are just symbols.

v(T⁡T)=f(T)31+f(T)30=(−1)3+(−1)1=−4v(T⁡1)=f(T)31+f(1)30=(−1)3+(1)1=−2v(1T)=f(1)31+f(T)30=(1)3+(−1)1=2v(11)=f(1)31+f(1)30=(1)3+(1)1=4v(1T⁡0)=f(1)32+f(T)31+f(0)30=(1)9+(−1)3+(0)1=6v(10T)=f(1)32+f(0)31+f(T)30=(1)9+(0)3+(−1)1=8 and using the above recurrence relation

v(101T)=f(1)33+v(01T)=(1)27+v(1T)=27+2=29.

Conversions to/from other representations

Conversion to decimal In the balanced ternary system the value of a digit n places left of the radix point is the product of the digit and 3n. This is useful when converting between decimal and balanced ternary. In the following the strings denoting balanced ternary carry the suffix, bal3. For instance,

10bal3 = 1 × 31 + 0 × 30 = 3dec 10𝖳bal3 = 1 × 32 + 0 × 31 + (−1) × 30 = 8dec −9dec = −1 × 32 + 0 × 31 + 0 × 30 = 𝖳00bal3 8dec = 1 × 32 + 0 × 31 + (−1) × 30 = 10𝖳bal3 Similarly, the first place to the right of the radix point holds 3−1 = ⁠1/3⁠, the second place holds 3−2 = ⁠1/9⁠, and so on. For instance,

−⁠2/3⁠dec = −1 + ⁠1/3⁠ = −1 × 30 + 1 × 3−1 = 𝖳.1bal3.

An integer is divisible by three if and only if the digit in the units place is zero. The parity of a balanced ternary integer may be checked by checking the parity of the sum of all trits. This sum has the same parity as the integer itself. Balanced ternary can also be extended to fractional numbers similar to how decimal numbers are written to the right of the radix point.

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Balanced ternary

Start with the simplest possible case. Write down what Balanced ternary claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Balanced ternary before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Balanced ternary ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Balanced ternary

In research
Balanced ternary appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Balanced ternary in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Balanced ternary is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer arithmetic, Non-standard positional numeral systems, Numeral systems, so understanding it makes those chapters shorter.
In everyday life
Look for Balanced ternary outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Balanced ternary” →

How to study Balanced ternary in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Balanced ternary means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Balanced ternary out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Balanced ternary in simple terms?

Balanced ternary is a ternary numeral system (i.e. base 3 with three digits) that uses a balanced signed-digit representation of the integers in which the digits have the values −1, 0, and 1. This stands in contrast to the standard (unbalanced) ternary system, in which digits have values 0, 1 and 2.

Why does Balanced ternary matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Balanced ternary?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Balanced ternary.

Tags

  • Computer arithmetic
  • Non-standard positional numeral systems
  • Numeral systems
  • Ternary computers

Keep exploring