Ternary Arithmetic
   HOME

TheInfoList



OR:

A ternary
numeral system A numeral system is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using digits or other symbols in a consistent manner. The same sequence of symbols may represent differe ...
(also called base 3 or trinary) has
three 3 (three) is a number, numeral and digit. It is the natural number following 2 and preceding 4, and is the smallest odd prime number and the only prime preceding a square number. It has religious and cultural significance in many societies ...
as its base. Analogous to a
bit The bit is the most basic unit of information in computing and digital communication. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represented as ...
, a ternary digit is a trit (trinary digit). One trit is equivalent to log2 3 (about 1.58496) bits of
information Information is an Abstraction, abstract concept that refers to something which has the power Communication, to inform. At the most fundamental level, it pertains to the Interpretation (philosophy), interpretation (perhaps Interpretation (log ...
. Although ''ternary'' most often refers to a system in which the three digits are all non–negative numbers; specifically , , and , the adjective also lends its name to the
balanced ternary Balanced ternary is a ternary numeral system (i.e. base 3 with three Numerical digit, 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 stand ...
system; comprising the digits
−1 In mathematics, −1 (negative one or minus one) is the additive inverse of 1, that is, the number that when added to 1 gives the additive identity element, 0. It is the negative integer greater than negative two (−2) and less than  0. ...
, 0 and +1, used in comparison logic and
ternary computer A ternary computer, also called trinary computer, is one that uses ternary logic (i.e., base 3) instead of the more common binary system (i.e., base 2) in its calculations. Ternary computers use trits, instead of binary bits. Types of states ...
s.


Comparison to other bases

Representations of
integer number An integer is the number zero ( 0), a positive natural number (1, 2, 3, ...), or the negation of a positive natural number ( −1, −2, −3, ...). The negations or additive inverses of the positive natural numbers are referred to as negative ...
s in ternary do not get uncomfortably lengthy as quickly as in
binary Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two values (0 and 1) for each digit * Binary function, a function that takes two arguments * Binary operation, a mathematical op ...
. For example,
decimal The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers (''decimal fractions'') of th ...
365 365 may refer to: * 365 (number), an integer * a common year, consisting of 365 calendar days * AD 365, a year of the Julian calendar * 365 BC, a year of the 4th century BC Media outlets * 365 (media corporation), Icelandic TV company * 365 ...
or
senary A senary () numeral system (also known as base-6, heximal, or seximal) has 6, six as its radix, base. It has been adopted independently by a small number of cultures. Like the decimal base 10, the base is a semiprime, though it is unique as the p ...
corresponds to binary (nine
bit The bit is the most basic unit of information in computing and digital communication. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represented as ...
s) and to ternary (six digits). However, they are still far less compact than the corresponding representations in bases such as
decimal The decimal numeral system (also called the base-ten positional numeral system and denary or decanary) is the standard system for denoting integer and non-integer numbers. It is the extension to non-integer numbers (''decimal fractions'') of th ...
– see below for a compact way to codify ternary using nonary (base 9) and septemvigesimal (base 27). : : : As for
rational number In mathematics, a rational number is a number that can be expressed as the quotient or fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (for example, The set of all ...
s, ternary offers a convenient way to represent as same as 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 (nor for , , etc.), because 2 is not a
prime A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways ...
factor Factor (Latin, ) may refer to: Commerce * Factor (agent), a person who acts for, notably a mercantile and colonial agent * Factor (Scotland), a person or firm managing a Scottish estate * Factors of production, such a factor is a resource used ...
of the base; as with base two, one-tenth (decimal, senary ) is not representable exactly (that would need e.g. decimal); nor is one-sixth (senary , decimal ). :


Sum of the digits in ternary as opposed to binary

The value of a binary number with ''n'' bits that are all 1 is . Similarly, for a number ''N''(''b'', ''d'') with base ''b'' and ''d'' digits, all of which are the maximal digit value , we can write: : : : . : and : , so : , or : Then : : : For a three-digit ternary number, .


Compact ternary representation: base 9 and 27

Nonary (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 Octal (base 8) is a numeral system with eight as the base. In the decimal system, each place is a power of ten. For example: : \mathbf_ = \mathbf \times 10^1 + \mathbf \times 10^0 In the octal system, each place is a power of eight. For ex ...
and
hexadecimal Hexadecimal (also known as base-16 or simply hex) is a Numeral system#Positional systems in detail, positional numeral system that represents numbers using a radix (base) of sixteen. Unlike the decimal system representing numbers using ten symbo ...
systems are used in place of
binary Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two values (0 and 1) for each digit * Binary function, a function that takes two arguments * Binary operation, a mathematical op ...
.


Practical usage

In certain analog logic, the state of the circuit is often expressed ternary. This is most commonly seen in
CMOS Complementary metal–oxide–semiconductor (CMOS, pronounced "sea-moss ", , ) is a type of MOSFET, metal–oxide–semiconductor field-effect transistor (MOSFET) semiconductor device fabrication, fabrication process that uses complementary an ...
circuits, and also in
transistor–transistor logic Transistor–transistor logic (TTL) is a logic family built from bipolar junction transistors (BJTs). Its name signifies that transistors perform both the logic function (the first "transistor") and the amplifying function (the second "transistor" ...
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 Voltage, also known as (electrical) potential difference, electric pressure, or electric tension, is the difference in electric potential between two points. In a Electrostatics, static electric field, it corresponds to the Work (electrical), ...
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 is for defensive statistics in American
baseball Baseball is a bat-and-ball games, bat-and-ball sport played between two team sport, teams of nine players each, taking turns batting (baseball), batting and Fielding (baseball), fielding. The game occurs over the course of several Pitch ...
(usually just for pitchers), to denote fractional parts of an inning. Since the team on offense is allowed three outs, each out is considered one third of a defensive inning and is denoted as .1. For example, if a player pitched all of the 4th, 5th and 6th innings, plus achieving 2 outs in the 7th inning, his
innings pitched In baseball, the statistic innings pitched (IP) is the number of innings a pitcher has completed, measured by the number of Batter (baseball), batters and baserunners that have been put out while the pitcher is on the Baseball field#Pitcher's mou ...
column for that game would be listed as 3.2, the equivalent of (which is sometimes used as an alternative by some record keepers). In this usage, only the fractional part of the number is written in ternary form. Ternary numbers can be used to convey self-similar structures like the Sierpinski triangle or the
Cantor set In mathematics, the Cantor set is a set of points lying on a single line segment that has a number of unintuitive properties. It was discovered in 1874 by Henry John Stephen Smith and mentioned by German mathematician Georg Cantor in 1883. Throu ...
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. 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 Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two values (0 and 1) for each digit * Binary function, a function that takes two arguments * Binary operation, a mathematical op ...
and
quaternary The Quaternary ( ) is the current and most recent of the three periods of the Cenozoic Era in the geologic time scale of the International Commission on Stratigraphy (ICS), as well as the current and most recent of the twelve periods of the ...
. This is due to its proximity to the
mathematical constant A mathematical constant is a number whose value is fixed by an unambiguous definition, often referred to by a special symbol (e.g., an Letter (alphabet), alphabet letter), or by mathematicians' names to facilitate using it across multiple mathem ...
''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. A form of redundant binary representation called a binary signed-digit number system, a form of
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 becau ...
, is sometimes used in low-level software and hardware to accomplish fast addition of integers because it can eliminate carries.


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. BCT encoding is analogous to
binary-coded decimal In computing and electronic systems, binary-coded decimal (BCD) is a class of binary encodings of decimal numbers where each digit is represented by a fixed number of bits, usually four or eight. Sometimes, special bit patterns are used f ...
(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 In theoretical computer science, the time complexity is the computational complexity that describes the amount of computer time it takes to run an algorithm. Time complexity is commonly estimated by counting the number of elementary operations p ...
. A library of C code supporting BCT arithmetic is available.


Tryte

Some
ternary computer A ternary computer, also called trinary computer, is one that uses ternary logic (i.e., base 3) instead of the more common binary system (i.e., base 2) in its calculations. Ternary computers use trits, instead of binary bits. Types of states ...
s such as the Setun defined a tryte to be six trits or approximately 9.5
bit The bit is the most basic unit of information in computing and digital communication. The name is a portmanteau of binary digit. The bit represents a logical state with one of two possible values. These values are most commonly represented as ...
s (holding more information than the ''de facto''
binary Binary may refer to: Science and technology Mathematics * Binary number, a representation of numbers using only two values (0 and 1) for each digit * Binary function, a function that takes two arguments * Binary operation, a mathematical op ...
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
).


See also

* Qutrit * Setun, a
ternary computer A ternary computer, also called trinary computer, is one that uses ternary logic (i.e., base 3) instead of the more common binary system (i.e., base 2) in its calculations. Ternary computers use trits, instead of binary bits. Types of states ...
*
Ternary logic In logic, a three-valued logic (also trinary logic, trivalent, ternary, or trilean, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating ''true'', ''false'', and some third value ...
* ''
Taixuanjing The ''Taixuanjing'' is a divination guide composed by the Confucian writer Yang Xiong (53 BCE18 CE) in the decade prior to the fall of the Western Han dynasty. The first draft of this work was completed in 2 BCE; during the Jin dynasty, an oth ...
''


References


Further reading

*


External links


Ternary Arithmetic



Ternary Base Conversion
ncludes fractional part, from Maths Is Fun
Gideon Frieder's replacement ternary numeral system

Visualization of ternary numeral system
{{DEFAULTSORT:Ternary Numeral System Computer arithmetic Positional numeral systems Ternary computers