Ternary numeral system

Short description: Base-3 numeral system

Numeral systems

Hindu–Arabic numeral system

* Western Arabic
* Eastern Arabic

* Bengali
* Devanagari
* Gurmukhi
* Sinhala
* Tamil

* Balinese
* Burmese
* Dzongkha
* Gujarati
* Javanese
* Khmer
* Lao
* Mongolian
* Thai

East Asian

* Chinese
* Suzhou
* Hokkien
* Japanese
* Korean
* Vietnamese
* Tangut

* Counting rods

Alphabetic

* Abjad
* Armenian
* Āryabhaṭa
* Cyrillic
* Ge'ez
* Georgian
* Greek
* Hebrew
* Roman

Former

* Aegean
* Attic
* Babylonian
* Brahmi
* Chuvash
* Egyptian
* Etruscan
* Glagolitic
* Inuit
* Kharosthi
* Mayan
* Muisca
* Quipu

* Prehistoric

Positional systems by base

* 2
* 3
* 4
* 5
* 6
* 8
* 10
* 12
* 16
* 20
* 60

Non-standard positional numeral systems

* Bijective numeration (1)
* Signed-digit representation (Balanced ternary)
* factorial
* negative
* Complex-base system (2i)
* Non-integer representation (φ)
* mixed
* Asymmetric numeral systems

List of numeral systems

* v
* t
* e

A ternary /ˈtɜːrnəri/ numeral system (also called base 3 or trinary[1]) has three as its base.

Although ternary most often refers to a system in which the three digits are all non-negative numbers (specifically 0, 1, and 2), the adjective also lends its name to the balanced ternary system. Comprising the digits −1, 0 and +1, balanced ternary is widely used in comparison logic and ternary computers.

## Contents

* 1 Information units
* 1.1 Trit
* 1.2 Tribble
* 1.3 Tryte
* 1.4 Word
* 1.5 Macro units
* 2 Comparison to other bases
* 2.1 Sum of the digits in ternary as opposed to binary
* 2.2 Compact ternary representation: base 9 and 27
* 3 Practical use
* 3.1 Balanced ternary advantages
* 3.2 Binary-coded ternary
* 4 See also
* 5 References
* 6 Further reading
* 7 External links

## Information units

### Trit

A ternary digit is a trit (trinary digit), analogously to a bit. One trit is equivalent to log2 3 (about 1.58496) bits of information.[2] Under classical hardware assumptions, base-3 is theoretically more efficient than binary in terms of radix economy, as 3 is the closest integer to Euler's number (e).[3]

### Tribble

Analogous to the binary nibble, a tribble consists of 3 trits. It can hold 27 distinct states (33 = 27), which is roughly equivalent to 4.75 bits of information. Because it has exactly 27 states, a tribble is conveniently represented by a single character in a septemvigesimal (base-27) alphanumeric notation.

### Tryte

Analogous to a binary byte, a tryte is typically defined as 6 or 9 trits. Early ternary computers, such as the Soviet Setun, defined a tryte to be six trits.[4] A six-trit tryte holds 36 = 729 states, carrying approximately 9.5 bits of information—significantly more than the standard 8-bit binary byte (256 states).[5] Modern theoretical architectures often favor a 9-trit tryte (39 = 19,683 states), as it cleanly divides into three tribbles.

### Word

A ternary word represents the standard register width for a given ternary architecture. The Setun computer, for instance, operated using an 18-trit word with 9-trit command and memory architectures.[5]

### Macro units

When scaling to larger data storage capacities, ternary computing nomenclature splits into two distinct conventions depending on the hardware architecture:

* Native ternary scaling: In a pure ternary system, macro-units scale by powers of 3 rather than the powers of 2 (1,024) or 10 (1,000) used in binary and decimal systems. A kilotryte (KT) in this system is exactly 310 (59,049) trytes. Following this pattern, a megatryte (MT) is 320 trytes, and a gigatryte (GT) is 330 trytes.
* Binary-compatible scaling: In hybrid systems designed to interface directly with existing binary infrastructure, engineers often map ternary groupings to standard binary sizes. Because 5 trits (243 states) fit efficiently within an 8-bit byte (256 states), traditional binary SI prefixes are sometimes applied directly to tryte blocks, making a kilotryte equal to 1,024 trytes, and a megatryte equal to 1,048,576 trytes.

## Comparison to other bases

Representations of integer numbers in ternary do not get uncomfortably lengthy as quickly as in binary. For example, decimal 36510 or senary 14056 corresponds to binary 1011011012 (nine bits) and to ternary 1111123 (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).

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 | 1000
11 | 11 | 22 | 110 | 121 | 202 | 220 | 1001 | 1012 | 1100
12 | 12 | 101 | 120 | 202 | 221 | 1010 | 1022 | 1111 | 1200
20 | 20 | 110 | 200 | 220 | 1010 | 1100 | 1120 | 1210 | 2000
21 | 21 | 112 | 210 | 1001 | 1022 | 1120 | 1211 | 2002 | 2100
22 | 22 | 121 | 220 | 1012 | 1111 | 1210 | 2002 | 2101 | 2200
100 | 100 | 200 | 1000 | 1100 | 1200 | 2000 | 2100 | 2200 | 10000
Numbers from 0 to 33 − 1 in standard ternary Ternary  | 0 | 1 | 2 | 10 | 11 | 12 | 20 | 21 | 22

|
|
|
|
|
|
|
|
|

Binary  | 0 | 1 | 10 | 11 | 100 | 101 | 110 | 111 | 1000
Senary  | 0 | 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12
Decimal  | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
Ternary  | 100 | 101 | 102 | 110 | 111 | 112 | 120 | 121 | 122
Binary  | 1001 | 1010 | 1011 | 1100 | 1101 | 1110 | 1111  | 10000 | 10001
Senary  | 13 | 14 | 15 | 20 | 21 | 22 | 23 | 24 | 25
Decimal  | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17
Ternary  | 200 | 201 | 202 | 210 | 211 | 212 | 220 | 221 | 222
Binary  | 10010 | 10011 | 10100 | 10101 | 10110 | 10111 | 11000 | 11001 | 11010
Senary  | 30 | 31 | 32 | 33 | 34 | 35 | 40 | 41 | 42
Decimal  | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26
Powers of 3 in ternary Ternary  | 1 | 10 | 100 | 1000 | 10000

|
|
|
|
|

Binary  | 1 | 11 | 1001 | 11011 | 1010001
Senary  | 1 | 3 | 13 | 43 | 213
Decimal  | 1 | 3 | 9 | 27 | 81
Power  | 30 | 31 | 32 | 33 | 34
Ternary  | 100000 | 1000000 | 10000000 | 100000000 | 1000000000
Binary  | 11110011 | 1011011001 | 100010001011 | 1100110100001 | 100110011100011
Senary  | 1043 | 3213 | 14043 | 50213 | 231043
Decimal  | 243 | 729 | 2187 | 6561 | 19683
Power  | 35 | 36 | 37 | 38 | 39

As for rational numbers, ternary offers a convenient way to represent ⁠1/3⁠ similar to 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 ⁠1/2⁠ (nor for ⁠1/4⁠, ⁠1/8⁠, etc.), because 2 has a prime factor that is not a factor of the base; as with base two, one-tenth (decimal ⁠1/10⁠, senary ⁠1/14⁠) is not representable exactly (that would need e.g. decimal); nor is one-sixth (senary ⁠1/10⁠, decimal ⁠1/6⁠).

Fractions in ternary Fraction  | ⁠1/2⁠ | ⁠1/3⁠ | ⁠1/4⁠ | ⁠1/5⁠ | ⁠1/6⁠ | ⁠1/7⁠ | ⁠1/8⁠ | ⁠1/9⁠ | ⁠1/10⁠ | ⁠1/11⁠ | ⁠1/12⁠ | ⁠1/13⁠

|
|
|
|
|
|
|
|
|
|
|
|

Ternary  | 0.1 | 0.1 | 0.02 | 0.0121 | 0.01 | 0.010212 | 0.01 | 0.01 | 0.0022 | 0.00211 | 0.002 | 0.002
Binary  | 0.1 | 0.01 | 0.01 | 0.0011 | 0.001 | 0.001 | 0.001 | 0.000111 | 0.00011 | 0.0001011101... | 0.0001 | 0.000100111011...
Senary  | 0.3 | 0.2 | 0.13 | 0.1 | 0.1 | 0.05 | 0.043 | 0.04 | 0.03 | 0.0313452421 | 0.03 | 0.024340531215
Decimal  | 0.5 | 0.3 | 0.25 | 0.2 | 0.16 | 0.142857 | 0.125  | 0.1 | 0.1 | 0.09 | 0.083 | 0.076923

### Sum of the digits in ternary as opposed to binary

The value of a binary number with n bits that are all 1 is 2n − 1.

Similarly, for a number N(b,d) with base b and d digits, all of which are the maximal digit value b−1, we can write the geometric progression:

N(b,d)=(b−1)bd−1+(b−1)bd−2+…+(b−1)b0=(b−1)(bd−1+bd−2+…+1)=(b−1)M.

Multiplying M by b yields: bM=bd+bd−1+…+b1

Subtracting M from bM isolates the boundary values: bM−M=bd−1 M=bd−1b−1

Substituting this back into the original equation for N(b,d) demonstrates that the maximum value for any base matches the boundary behavior of binary: N(b,d)=(b−1)(bd−1b−1)=bd−1.

For a three-digit ternary number, N(3,3)=33−1=26=(2×32)+(2×31)+(2×30)=18+6+2.

### Compact ternary representation: base 9 and 27

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 /ˈnɒnəri/ (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

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 34 = 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 occurs in defensive statistics in American baseball (specifically for pitchers) to denote fractional parts of an inning. Because an offensive team is allowed three outs per half-inning, each out represents exactly one-third of a defensive inning and is colloquially written as a decimal point followed by the number of outs.

For example, if a player pitches all of the 4th, 5th, and 6th innings, and records exactly 2 outs in the 7th inning, their innings pitched (IP) statistic would be listed as 3.2. This represents ⁠3+2/3⁠ innings pitched (a notation sometimes preferred by traditional record keepers). In this specific sport context, only the fractional part of the number is structurally calculated in base 3.[6]

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.[7][8] Any terminating expansion in the ternary system is equivalent to the expression that is identical up to the term preceding the last non-zero term followed by the term one less than the last non-zero term of the first expression, followed by an infinite tail of twos. For example: 0.1020 is equivalent to 0.1012222... because the expansions are the same until the "two" of the first expression, the two was decremented in the second expansion, and trailing zeros were replaced with trailing twos in the second expression.

Ternary is the integer base with the lowest radix economy, followed closely by binary and quaternary. This is due to its proximity to the mathematical constant e. It has been used for some computing systems because of this efficiency. It is also used to represent three-option trees, such as phone menu systems, which allow a simple path to any branch.

### Balanced ternary advantages

When implemented as balanced ternary (comprising the digits −1, 0, and +1), the numeral system offers distinct computational advantages over binary. Most notably, balanced ternary eliminates the need for an explicit sign bit, as the sign of a number is inherently determined by its most significant non-zero digit. Furthermore, mathematical negation is highly efficient, requiring only a simple entrywise inversion of symbols (swapping +1s and −1s) rather than the complex two's complement operations required by binary hardware.[9]

A form of redundant binary representation called a binary signed-digit number system, a form of signed-digit representation, is sometimes used in low-level software and hardware to accomplish fast addition of integers because it can eliminate carries.[10]

### Binary-coded ternary

Simulation of ternary computers using binary computers, or interfacing between ternary and binary computers, can involve use of binary-coded ternary (BCT) numbers, with two or three bits used to encode each trit.[11][12] BCT encoding is analogous to binary-coded decimal (BCD) encoding. If the trit values 0, 1 and 2 are encoded 00, 01 and 10, conversion in either direction between binary-coded ternary and binary can be done in logarithmic time.[13] A library of C code supporting BCT arithmetic is available.[14]

## See also

* Qutrit
* Setun, a ternary computer
* Ternary logic
* Taixuanjing

## References

1. ↑ Kindra, Vladimir; Rogalev, Nikolay; Osipov, Sergey; Zlyvko, Olga; Naumov, Vladimir (2022). "Research and Development of Trinary Power Cycles" (in en). Inventions 7 (3): 56. doi:10.3390/inventions7030056. ISSN 2411-5134.
2. ↑ Etiemble, Daniel (2019). "Ternary circuits: why R=3 is not the Optimal Radix for Computation". arXiv:1908.06841 [cs.AR].
3. ↑ Georgiou, Harris V. (2016). "On the optimality of ternary arithmetic for compactness and hardware design". arXiv:1611.03715 [cs.AR].
4. ↑ "Perspectives on Soviet and Russian Computing". First IFIP WG 9.7 Conference, SoRuCom 2006. Petrozavodsk, Russia: Springer. 2006. ISBN 978-3-64222816-2. https://books.google.com/books?id=-jSqCAAAQBAJ.
5. ↑ 5.0 5.1 "Development of ternary computers at Moscow State University". https://www.computer-museum.ru/english/setun.htm.
6. ↑ Ashley MacLennan (Jan 9, 2019). "A complete beginner's guide to baseball stats: Pitching statistics, and what they mean". Bless You Boys. https://www.blessyouboys.com/2019/1/9/18172095/baseball-stats-for-beginners-earned-run-average-field-independent-pitching-explained.
7. ↑ "On A sequence of cantor Fractals". Rose Hulman Undergraduate Mathematics Journal 7 (1). 2006. Paper 9.
8. ↑ "A Different Description of A Family of Middle–α Cantor Sets". American Journal of Undergraduate Research 5 (2): 9–12. 2006.
9. ↑ Cambou, Bertrand; Telesca, Donald (2018). "Ternary Computing to Strengthen Cybersecurity". Advances in Intelligent Systems and Computing. pp. 898–919. doi:10.1007/978-3-030-01177-2_67. ISBN 978-3-030-01176-5.
10. ↑ "Hybrid signed–digit number systems: a unified framework for redundant number representations with bounded carry propagation chains". IEEE Transactions on Computers 43 (8): 880–891. 1994. doi:10.1109/12.295850. https://www.cs.umbc.edu/~phatak/publications/hsdtrc.pdf.
11. ↑ "Algorithms for Binary Coded Balanced and Ordinary Ternary Operations". IEEE Transactions on Computers C-24 (2): 212–215. February 1975. doi:10.1109/T-C.1975.224188.
12. ↑ "Arithmetic with binary-encoded balanced ternary numbers". 2013 Asilomar Conference on Signals, Systems and Computers. Pacific Grove, California, US. 2013-11-03. pp. 1130–1133. doi:10.1109/ACSSC.2013.6810470. ISBN 978-1-4799-2390-8.
13. ↑ "Binary Coded Ternary and its Inverse". June 2016. https://www.cs.uiowa.edu/~jones/ternary/bct.shtml.
14. ↑ "Ternary Data Types for C Programmers". 2015-12-29. https://www.cs.uiowa.edu/~jones/ternary/libtern.shtml.

## Further reading

* "Third base". American Scientist (Sigma Xi, the Scientific Research Society) 89 (6): 490–494. November–December 2001. doi:10.1511/2001.40.3268. http://bit-player.org/wp-content/extras/bph-publications/AmSci-2001-11-Hayes-ternary.pdf. Retrieved 2020-04-12.

## External links

* Ternary Arithmetic
* The ternary calculating machine of Thomas Fowler
* Ternary Base Conversion - includes fractional part, from Maths Is Fun
* Gideon Frieder's replacement ternary numeral system
* Visualization of ternary numeral system

* v
* t
* e

Data types

Uninterpreted|

* Bit
* Byte
* Trit
* Tryte
* Word
* Bit array

Numeric|

* Arbitrary-precision or bignum
* Complex
* Decimal
* Fixed point
* Floating point
* Double precision
* Extended precision
* Long double
* Octuple precision
* Quadruple precision
* Single precision
* Reduced precision
* Minifloat
* Half precision
* bfloat16
* Integer
* signedness
* Interval
* Rational

Pointer|

* Address
* physical
* virtual
* Reference

Text|

* Character
* String
* null-terminated

Composite|

* Algebraic data type
* generalized
* Array
* Associative array
* Class
* Dependent
* Equality
* Inductive
* Intersection
* List
* Object
* metaobject
* Option type
* Product
* Record or Struct
* Refinement
* Set
* Union
* tagged

Other|

* Boolean
* Bottom type
* Collection
* Enumerated type
* Exception
* Function type
* Opaque data type
* Recursive data type
* Semaphore
* Stream
* Top type
* Type class
* Unit type
* Void

Related
topics|

* Abstract data type
* Data structure
* Generic
* Kind
* metaclass
* Parametric polymorphism
* Primitive data type
* Protocol
* interface
* Subtyping
* Type constructor
* Type conversion
* Type system
* Type theory

See also platform-dependent and independent units of information

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/Ternary numeral system. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=Ternary_numeral_system&oldid=4566320"
*[v]: View this template
*[t]: Discuss this template
*[e]: Edit this template