Let \mathcal{D}_{3} := \lbrace \operatorname{T}, 0, 1 \rbrace denote the set of
symbols (also called
glyphs or
characters), where the symbol \bar{1} is sometimes used in place of \operatorname{T}. Define an
integer-valued function f = f_{\mathcal{D}_{3}} : \mathcal{D}_{3} \to \mathbb{Z} by :\begin{align} f_{}(\operatorname{T}) &= -1, \\ f_{}(0) &= 0, \\ f_{}(1) &= 1, \end{align} 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 \mathcal{D}_{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 \mathcal{D}_{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 \mathcal{D}_{3}^{+} be the
Kleene plus of \mathcal{D}_{3}, which is the set of all finite length
concatenated strings d_n \ldots d_0 of one or more symbols (called its
digits) where n is a non-negative integer and all n + 1 digits d_n, \ldots, d_0 are taken from \mathcal{D}_{3} = \lbrace \operatorname{T}, 0, 1 \rbrace. The
start of d_n \ldots d_0 is the symbol d_0 (at the right), its
end is d_n (at the left), and its
length is n + 1. The
ternary evaluation is the function v = v_{3} ~:~ \mathcal{D}_{3}^{+} \to \mathbb{Z} defined by assigning to every string d_n \ldots d_0 \in \mathcal{D}_{3}^{+} the integer :v\left( d_n \ldots d_0 \right) ~=~ \sum_{i=0}^{n} f_{} \left( d_{i} \right) 3^{i}. The string d_n \ldots d_0
represents (with respect to v) the integer v\left( d_n \ldots d_0 \right). The value v\left( d_n \ldots d_0 \right) may alternatively be denoted by {d_n \ldots d_0}_{\operatorname{bal}3}. The map v : \mathcal{D}_{3}^{+} \to \mathbb{Z} is
surjective but not injective since, for example, 0 = v(0) = v(00) = v(0 0 0) = \cdots. However, every nonzero integer has exactly one representation under v that does not
end (on the left) with the symbol 0, i.e. d_n = 0 . If d_n \ldots d_0 \in \mathcal{D}_{3}^{+} and n > 0 then v satisfies: :v\left( d_n d_{n-1} \ldots d_0 \right) ~=~ f_{} \left( d_{n} \right) 3^{n} + v\left( d_{n-1} \ldots d_0 \right) which shows that v satisfies a sort of
recurrence relation. This recurrence relation has the initial condition v\left( \varepsilon \right) = 0 where \varepsilon is the empty string. This implies that for every string d_n \ldots d_0 \in \mathcal{D}_{3}^{+}, :v\left( 0 d_n \ldots d_0 \right) = v\left( d_n \ldots d_0 \right) 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 \mathcal{D}_{3}^{+} are just symbols. :\begin{alignat}{10} v\left( \operatorname{T} \operatorname{T} \right) &= && f_{}\left( \operatorname{T} \right) 3^{1} + && f_{}\left( \operatorname{T} \right) 3^{0} &&= &&(-1) &&3 &&\,+\, &&(-1) &&1 &&= -4 \\ v\left( \operatorname{T} 1 \right) &= && f_{}\left( \operatorname{T} \right) 3^{1} + && f_{}\left( 1 \right) 3^{0} &&= &&(-1) &&3 &&\,+\, &&(1) &&1 &&= -2 \\ v\left( 1 \operatorname{T} \right) &= && f_{}\left( 1 \right) 3^{1} + && f_{}\left( \operatorname{T} \right) 3^{0} &&= &&(1) &&3 &&\,+\, &&(-1) &&1 &&= 2 \\ v\left( 1 1 \right) &= && f_{}\left( 1 \right) 3^{1} + && f_{}\left( 1 \right) 3^{0} &&= &&(1) &&3 &&\,+\, &&(1) &&1 &&= 4 \\ v\left( 1 \operatorname{T} 0 \right) &= f_{}\left( 1 \right) 3^{2} + && f_{}\left( \operatorname{T} \right) 3^{1} + && f_{}\left( 0 \right) 3^{0} &&= (1) 9 \,+\, &&(-1) &&3 &&\,+\, &&(0) &&1 &&= 6 \\ v\left( 1 0 \operatorname{T} \right) &= f_{}\left( 1 \right) 3^{2} + && f_{}\left( 0 \right) 3^{1} + && f_{}\left( \operatorname{T} \right) 3^{0} &&= (1) 9 \,+\, &&(0) &&3 &&\,+\, &&(-1) &&1 &&= 8 \\ \end{alignat} and using the above recurrence relation :v\left( 1 0 1 \operatorname{T} \right) = f_{}\left( 1 \right) 3^{3} + v\left( 0 1 \operatorname{T} \right) = (1) 27 + v\left( 1 \operatorname{T} \right) = 27 + 2 = 29. == Conversions to/from other representations ==