# Signed-digit representation

In mathematical notation for numbers, a signed-digit representation is a positional numeral system with a set of signed digits used to encode the integers.

Signed-digit representation can be used to accomplish fast addition of integers because it can eliminate chains of dependent carries.[1] In the binary numeral system, a special case signed-digit representation is the non-adjacent form, which can offer speed benefits with minimal space overhead.

## History

Challenges in calculation stimulated early authors Colson (1726) and Cauchy (1840) to use signed-digit representation. The further step of replacing negated digits with new ones was suggested by Selling (1887) and Cajori (1928).

In 1928, Florian Cajori noted the recurring theme of signed digits, starting with Colson (1726) and Cauchy (1840).[2] In his book History of Mathematical Notations, Cajori titled the section "Negative numerals".[3] For completeness, Colson[4] uses examples and describes addition (pp 163,4), multiplication (pp 165,6) and division (pp 170,1) using a table of multiples of the divisor. He explains the convenience of approximation by truncation in multiplication. Colson also devised an instrument (Counting Table) that calculated using signed digits.

Eduard Selling[5] advocated inverting the digits 1, 2, 3, 4, and 5 to indicate the negative sign. He also suggested snie, jes, jerd, reff, and niff as names to use vocally. Most of the other early sources used a bar over a digit to indicate a negative sign for a it. Another German usage of signed-digits was described in 1902 in Klein's encyclopedia.[6]

## Definition and properties

### Digit set

Let ${\displaystyle {\mathcal {D}}}$  be a finite set of numerical digits with cardinality ${\displaystyle b>1}$  (If ${\displaystyle b\leq 1}$ , then the positional number system is trivial and only represents the trivial ring), with each digit denoted as ${\displaystyle d_{i}}$  for ${\displaystyle 0\leq i . ${\displaystyle b}$  is known as the radix or number base. ${\displaystyle {\mathcal {D}}}$  can be used for a signed-digit representation if there exists a unique function ${\displaystyle f_{\mathcal {D}}:{\mathcal {D}}\rightarrow \mathbb {Z} }$  such that ${\displaystyle f_{\mathcal {D}}(d_{i})\equiv i{\bmod {b}}}$ .

${\displaystyle {\mathcal {D}}}$  can be partitioned into three distinct sets ${\displaystyle {\mathcal {D}}_{+}}$ , ${\displaystyle {\mathcal {D}}_{0}}$ , and ${\displaystyle {\mathcal {D}}_{-}}$ , representing the positive, zero, and negative digits respectively, such that all digits ${\displaystyle d_{+}\in {\mathcal {D}}_{+}}$  satisfy ${\displaystyle f_{\mathcal {D}}(d_{+})>0}$ , all digits ${\displaystyle d_{0}\in {\mathcal {D}}_{0}}$  satisfy ${\displaystyle f_{\mathcal {D}}(d_{0})=0}$  and all digits ${\displaystyle d_{-}\in {\mathcal {D}}_{-}}$  satisfy ${\displaystyle f_{\mathcal {D}}(d_{-})<0}$ . The cardinality of ${\displaystyle {\mathcal {D}}_{+}}$  is ${\displaystyle b_{+}}$ , the cardinality of ${\displaystyle {\mathcal {D}}_{0}}$  is ${\displaystyle b_{0}}$ , and the cardinality of ${\displaystyle {\mathcal {D}}_{-}}$  is ${\displaystyle b_{-}}$ , giving the number of positive and negative digits respectively, such that ${\displaystyle b=b_{+}+b_{0}+b_{-}}$ .

#### Balanced form representations

Balanced form representations are representations where for every positive digit ${\displaystyle d_{+}}$ , there exist a corresponding negative digit ${\displaystyle d_{-}}$  such that ${\displaystyle f_{\mathcal {D}}(d_{+})=-f_{\mathcal {D}}(d_{-})}$ . It follows that ${\displaystyle b_{+}=b_{-}}$ . Only odd bases can have balanced form representations, as when ${\displaystyle b_{+}=b_{-}}$ , ${\displaystyle b=b_{+}+b_{-}+1}$  is always an odd number. In balanced form, the negative digits ${\displaystyle d_{-}\in {\mathcal {D}}_{-}}$  are usually denoted as positive digits with a bar over the digit, as ${\displaystyle d_{-}={\bar {d}}_{+}}$  for ${\displaystyle d_{+}\in {\mathcal {D}}_{+}}$ . For example, the digit set of balanced ternary would be ${\displaystyle {\mathcal {D}}_{3}=\lbrace {\bar {1}},0,1\rbrace }$  with ${\displaystyle f_{{\mathcal {D}}_{3}}({\bar {1}})=-1}$ , ${\displaystyle f_{{\mathcal {D}}_{3}}(0)=0}$ , and ${\displaystyle f_{{\mathcal {D}}_{3}}(1)=1}$ . This convention is adopted in finite fields of odd prime order ${\displaystyle q}$ :[7]

${\displaystyle \mathbb {F} _{q}=\lbrace 0,1,{\bar {1}}=-1,...d={\frac {q-1}{2}},\ {\bar {d}}={\frac {1-q}{2}}\ |\ q=0\rbrace .}$

#### Dual signed-digit representation

Every digit set ${\displaystyle {\mathcal {D}}}$  has a dual digit set ${\displaystyle {\mathcal {D}}^{\operatorname {op} }}$  given by the inverse order of the digits with an isomorphism ${\displaystyle g:{\mathcal {D}}\rightarrow {\mathcal {D}}^{\operatorname {op} }}$  defined by ${\displaystyle -f_{\mathcal {D}}=g\circ f_{{\mathcal {D}}^{\operatorname {op} }}}$ . As a result, for any signed-digit representations ${\displaystyle {\mathcal {N}}}$  of a number system ring ${\displaystyle N}$  constructed from ${\displaystyle {\mathcal {D}}}$  with valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {N}}\rightarrow N}$ , there exists a dual signed-digit representations of ${\displaystyle N}$ , ${\displaystyle {\mathcal {N}}^{\operatorname {op} }}$ , constructed from ${\displaystyle {\mathcal {D}}^{\operatorname {op} }}$  with valuation ${\displaystyle v_{{\mathcal {D}}^{\operatorname {op} }}:{\mathcal {N}}^{\operatorname {op} }\rightarrow N}$ , and an isomorphism ${\displaystyle h:{\mathcal {N}}\rightarrow {\mathcal {N}}^{\operatorname {op} }}$  defined by ${\displaystyle -v_{\mathcal {D}}=h\circ v_{{\mathcal {D}}^{\operatorname {op} }}}$ , where ${\displaystyle -}$  is the additive inverse operator of ${\displaystyle N}$ . The digit set for balanced form representations is self-dual.

### For integers

Given the digit set ${\displaystyle {\mathcal {D}}}$  and function ${\displaystyle f:{\mathcal {D}}\rightarrow \mathbb {Z} }$  as defined above, let us define an integer endofunction ${\displaystyle T:\mathbb {Z} \rightarrow \mathbb {Z} }$  as the following:

${\displaystyle T(n)={\begin{cases}{\frac {n-f(d_{i})}{b}}&{\text{if }}n\equiv i{\bmod {b}},0\leq i

If the only periodic point of ${\displaystyle T}$  is the fixed point ${\displaystyle 0}$ , then the set of all signed-digit representations of the integers ${\displaystyle \mathbb {Z} }$  using ${\displaystyle {\mathcal {D}}}$  is given by the Kleene plus ${\displaystyle {\mathcal {D}}^{+}}$ , the set of all finite concatenated strings of digits ${\displaystyle d_{n}\ldots d_{0}}$  with at least one digit, with ${\displaystyle n\in \mathbb {N} }$ . Each signed-digit representation ${\displaystyle m\in {\mathcal {D}}^{+}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {D}}^{+}\rightarrow \mathbb {Z} }$

${\displaystyle v_{\mathcal {D}}(m)=\sum _{i=0}^{n}f_{\mathcal {D}}(d_{i})b^{i}}$ .

Examples include balanced ternary with digits ${\displaystyle {\mathcal {D}}=\lbrace {\bar {1}},0,1\rbrace }$ .

Otherwise, if there exist a non-zero periodic point of ${\displaystyle T}$ , then there exist integers that are represented by an infinite number of non-zero digits in ${\displaystyle {\mathcal {D}}}$ . Examples include the standard decimal numeral system with the digit set ${\displaystyle \operatorname {dec} =\lbrace 0,1,2,3,4,5,6,7,8,9\rbrace }$ , which requires an infinite number of the digit ${\displaystyle 9}$  to represent the additive inverse ${\displaystyle -1}$ , as ${\displaystyle T_{\operatorname {dec} }(-1)={\frac {-1-9}{10}}=-1}$ , and the positional numeral system with the digit set ${\displaystyle {\mathcal {D}}=\lbrace {\text{A}},0,1\rbrace }$  with ${\displaystyle f({\text{A}})=-4}$ , which requires an infinite number of the digit ${\displaystyle {\text{A}}}$  to represent the number ${\displaystyle 2}$ , as ${\displaystyle T_{\mathcal {D}}(2)={\frac {2-(-4)}{3}}=2}$ .

### For decimal fractions

If the integers can be represented by the Kleene plus ${\displaystyle {\mathcal {D}}^{+}}$ , then the set of all signed-digit representations of the decimal fractions, or ${\displaystyle b}$ -adic rationals ${\displaystyle \mathbb {Z} [1\backslash b]}$ , is given by ${\displaystyle {\mathcal {Q}}={\mathcal {D}}^{+}\times {\mathcal {P}}\times {\mathcal {D}}^{*}}$ , the Cartesian product of the Kleene plus ${\displaystyle {\mathcal {D}}^{+}}$ , the set of all finite concatenated strings of digits ${\displaystyle d_{n}\ldots d_{0}}$  with at least one digit, the singleton ${\displaystyle {\mathcal {P}}}$  consisting of the radix point (${\displaystyle .}$  or ${\displaystyle ,}$ ), and the Kleene star ${\displaystyle {\mathcal {D}}^{*}}$ , the set of all finite concatenated strings of digits ${\displaystyle d_{-1}\ldots d_{-m}}$ , with ${\displaystyle m,n\in \mathbb {N} }$ . Each signed-digit representation ${\displaystyle q\in {\mathcal {Q}}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {Q}}\rightarrow \mathbb {Z} [1\backslash b]}$

${\displaystyle v_{\mathcal {D}}(q)=\sum _{i=-m}^{n}f_{\mathcal {D}}(d_{i})b^{i}}$

### For real numbers

If the integers can be represented by the Kleene plus ${\displaystyle {\mathcal {D}}^{+}}$ , then the set of all signed-digit representations of the real numbers ${\displaystyle \mathbb {R} }$  is given by ${\displaystyle {\mathcal {R}}={\mathcal {D}}^{+}\times {\mathcal {P}}\times {\mathcal {D}}^{\mathbb {N} }}$ , the Cartesian product of the Kleene plus ${\displaystyle {\mathcal {D}}^{+}}$ , the set of all finite concatenated strings of digits ${\displaystyle d_{n}\ldots d_{0}}$  with at least one digit, the singleton ${\displaystyle {\mathcal {P}}}$  consisting of the radix point (${\displaystyle .}$  or ${\displaystyle ,}$ ), and the Cantor space ${\displaystyle {\mathcal {D}}^{\mathbb {N} }}$ , the set of all infinite concatenated strings of digits ${\displaystyle d_{-1}d_{-2}\ldots }$ , with ${\displaystyle n\in \mathbb {N} }$ . Each signed-digit representation ${\displaystyle r\in {\mathcal {R}}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {R}}\rightarrow \mathbb {R} }$

${\displaystyle v_{\mathcal {D}}(r)=\sum _{i=-\infty }^{n}f_{\mathcal {D}}(d_{i})b^{i}}$ .

The infinite series always converges to a finite real number.

### For other number systems

All base-${\displaystyle b}$  numerals can be represented as a subset of ${\displaystyle {\mathcal {D}}^{\mathbb {Z} }}$ , the set of all doubly infinite sequences of digits in ${\displaystyle {\mathcal {D}}}$ , where ${\displaystyle \mathbb {Z} }$  is the set of integers, and the ring of base-${\displaystyle b}$  numerals is represented by the formal power series ring ${\displaystyle \mathbb {Z} [[b,b^{-1}]]}$ , the doubly infinite series

${\displaystyle \sum _{i=-\infty }^{\infty }a_{i}b^{i}}$

where ${\displaystyle a_{i}\in \mathbb {Z} }$  for ${\displaystyle i\in \mathbb {Z} }$ .

#### Integers modulo ${\displaystyle b^{n}}$

The set of all signed-digit representations of the integers modulo ${\displaystyle b^{n}}$ , ${\displaystyle \mathbb {Z} \backslash b^{n}\mathbb {Z} }$  is given by the set ${\displaystyle {\mathcal {D}}^{n}}$ , the set of all finite concatenated strings of digits ${\displaystyle d_{n-1}\ldots d_{0}}$  of length ${\displaystyle n}$ , with ${\displaystyle n\in \mathbb {N} }$ . Each signed-digit representation ${\displaystyle m\in {\mathcal {D}}^{n}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {D}}^{n}\rightarrow \mathbb {Z} /b^{n}\mathbb {Z} }$

${\displaystyle v_{\mathcal {D}}(m)\equiv \sum _{i=0}^{n-1}f_{\mathcal {D}}(d_{i})b^{i}{\bmod {b}}^{n}}$

#### Prüfer groups

A Prüfer group is the quotient group ${\displaystyle \mathbb {Z} (b^{\infty })=\mathbb {Z} [1\backslash b]/\mathbb {Z} }$  of the integers and the ${\displaystyle b}$ -adic rationals. The set of all signed-digit representations of the Prüfer group is given by the Kleene star ${\displaystyle {\mathcal {D}}^{*}}$ , the set of all finite concatenated strings of digits ${\displaystyle d_{1}\ldots d_{n}}$ , with ${\displaystyle n\in \mathbb {N} }$ . Each signed-digit representation ${\displaystyle p\in {\mathcal {D}}^{*}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {D}}^{*}\rightarrow \mathbb {Z} (b^{\infty })}$

${\displaystyle v_{\mathcal {D}}(m)\equiv \sum _{i=1}^{n}f_{\mathcal {D}}(d_{i})b^{-i}{\bmod {1}}}$

#### Circle group

The circle group is the quotient group ${\displaystyle \mathbb {T} =\mathbb {R} /\mathbb {Z} }$  of the integers and the real numbers. The set of all signed-digit representations of the circle group is given by the Cantor space ${\displaystyle {\mathcal {D}}^{\mathbb {N} }}$ , the set of all right-infinite concatenated strings of digits ${\displaystyle d_{1}d_{2}\ldots }$ . Each signed-digit representation ${\displaystyle m\in {\mathcal {D}}^{n}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {D}}^{\mathbb {N} }\rightarrow \mathbb {T} }$

${\displaystyle v_{\mathcal {D}}(m)\equiv \sum _{i=1}^{\infty }f_{\mathcal {D}}(d_{i})b^{-i}{\bmod {1}}}$

The infinite series always converges.

#### ${\displaystyle b}$ -adic integers

The set of all signed-digit representations of the ${\displaystyle b}$ -adic integers, ${\displaystyle \mathbb {Z} _{b}}$  is given by the Cantor space ${\displaystyle {\mathcal {D}}^{\mathbb {N} }}$ , the set of all left-infinite concatenated strings of digits ${\displaystyle \ldots d_{1}d_{0}}$ . Each signed-digit representation ${\displaystyle m\in {\mathcal {D}}^{n}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {D}}^{\mathbb {N} }\rightarrow \mathbb {Z} _{b}}$

${\displaystyle v_{\mathcal {D}}(m)=\sum _{i=0}^{\infty }f_{\mathcal {D}}(d_{i})b^{i}}$

#### ${\displaystyle b}$ -adic solenoids

The set of all signed-digit representations of the ${\displaystyle b}$ -adic solenoids, ${\displaystyle \mathbb {T} _{b}}$  is given by the Cantor space ${\displaystyle {\mathcal {D}}^{\mathbb {Z} }}$ , the set of all doubly infinite concatenated strings of digits ${\displaystyle \ldots d_{1}d_{0}d_{-1}\ldots }$ . Each signed-digit representation ${\displaystyle m\in {\mathcal {D}}^{n}}$  has a valuation ${\displaystyle v_{\mathcal {D}}:{\mathcal {D}}^{\mathbb {Z} }\rightarrow \mathbb {T} _{b}}$

${\displaystyle v_{\mathcal {D}}(m)=\sum _{i=-\infty }^{\infty }f_{\mathcal {D}}(d_{i})b^{i}}$

## In written and spoken language

The oral and written forms of numbers in the Punjabi language use a form of a negative numeral one written as una or un.[8] This negative one is used to form 19, 29, …, 89 from the root for 20, 30, …, 90. Explicitly, here are the numbers:

• 19 unni, 20 vih, 21 ikki
• 29 unatti, 30 tih, 31 ikatti
• 39 untali, 40 chali, 41 iktali
• 49 unanja, 50 panjah, 51 ikvanja
• 59 unahat, 60 sath, 61 ikahat
• 69 unattar, 70 sattar, 71 ikhattar
• 79 unasi, 80 assi, 81 ikiasi
• 89 unanve, 90 nabbe, 91 ikinnaven.

Similarly, the Sesotho language utilizes negative numerals to form 8's and 9's.

• 8 robeli (/Ro-bay-dee/) meaning "break two" i.e. two fingers down
• 9 robong (/Ro-bong/) meaning "break one" i.e. one finger down

In the English language it is common to refer to times as, for example, 'seven til three', 'til' performing the negation.

## Other systems

There exist other signed-digit bases such that the base ${\displaystyle b\neq b_{+}+b_{-}+1}$ . A notable examples of this is Booth encoding, which has a digit set ${\displaystyle {\mathcal {D}}=\lbrace {\bar {1}},0,1\rbrace }$  with ${\displaystyle b_{+}=1}$  and ${\displaystyle b_{-}=1}$ , but which uses a base ${\displaystyle b=2<3=b_{+}+b_{-}+1}$ . The standard binary numeral system would only use digits of value ${\displaystyle \lbrace 0,1\rbrace }$ .

Note that non-standard signed-digit representations are not unique. For instance:

${\displaystyle 0111_{\mathcal {D}}=4+2+1=7}$
${\displaystyle 10{\bar {1}}1_{\mathcal {D}}=8-2+1=7}$
${\displaystyle 1{\bar {1}}11_{\mathcal {D}}=8-4+2+1=7}$
${\displaystyle 100{\bar {1}}_{\mathcal {D}}=8-1=7}$

The non-adjacent form (NAF) of Booth encoding does guarantee a unique representation for every integer value. However, this only applies for integer values. For example, consider the following repeating binary numbers in NAF,

${\displaystyle {\frac {2}{3}}=0.{\overline {10}}_{\mathcal {D}}=1.{\overline {0{\bar {1}}}}_{\mathcal {D}}}$