A ternary _{2} 3 (about 1.58496) bits of

binary
Binary may refer to:
Science and technology
Mathematics
* Binary number
In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: ty ...

Ternary Arithmetic

Ternary Base Conversion

ncludes fractional part, from Maths Is Fun

Gideon Frieder's replacement ternary numeral system

{{DEFAULTSORT:Ternary Numeral System Computer arithmetic Positional numeral systems Ternary computers

numeral system
A numeral system (or system of numeration) is a writing system for expressing numbers; that is, a mathematical notation for representing numbers of a given set, using Numerical digit, digits or other symbols in a consistent manner.
The same s ...

(also called base 3 or trinary) has three
3 is a number, numeral, and glyph.
3, three, or III may also refer to:
* AD 3, the third year of the AD era
* 3 BC, the third year before the AD era
* March, the third month
Books
* '' Three of Them'' (Russian: ', literally, "three"), a 1901 ...

as its base
Base or BASE may refer to:
Brands and enterprises
* Base (mobile telephony provider), a Belgian mobile telecommunications operator
*Base CRM
Base CRM (originally Future Simple or PipeJump) is an enterprise software company based in Mountain Vie ...

. Analogous to a bit
The bit is a basic unit of information in computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithm
of an algorithm (Euclid's algo ...

, a ternary digit
Digit may refer to:
Mathematics and science
* Numerical digit, as used in mathematics or computer science
** Arabic numerals, the most common modern representation of numerical digits
* Digit (anatomy), one of several most distal parts of a limb ...

is a trit (trinary digit). One trit is equivalent to loginformation
Information is processed, organised and structured data
Data (; ) are individual facts
A fact is something that is truth, true. The usual test for a statement of fact is verifiability—that is whether it can be demonstrated to c ...

.
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 digits) that uses a balanced signed-digit representation of the integer
An integer (from the Latin
Latin (, or , ) is a classical language belonging to the Italic langua ...

system; comprising the digits −1
In mathematics
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, analysis). It ...

, 0 and +1, used in comparison logic and ternary computer
A ternary computer (also called trinary computer) is a computer that uses ternary logic (three possible values) instead of the more popular Binary number, binary system ("Base 2") in its calculations.
Types of states
Ternary computing deals with th ...

s.
Comparison to other bases

Representations ofinteger number
An integer (from the Latin wikt:integer#Latin, ''integer'' meaning "whole") is colloquially defined as a number that can be written without a Fraction (mathematics), fractional component. For example, 21, 4, 0, and −2048 are integers, while ...

s in ternary do not get uncomfortably lengthy as quickly as in binary
Binary may refer to:
Science and technology
Mathematics
* Binary number
In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: ty ...

. For example, decimal
The decimal numeral system
A numeral system (or system of numeration) is a writing system
A writing system is a method of visually representing verbal communication
Communication (from Latin ''communicare'', meaning "to share") is t ...

365 or senary
A senary () numeral system
A numeral system (or system of numeration) is a writing system
A writing system is a method of visually representing verbal communication
Communication (from Latin ''communicare'', meaning "to share") is t ...

1405 corresponds to binary 101101101 (nine digits) and to ternary 111112 (six digits). However, they are still far less compact than the corresponding representations in bases such as decimal
The decimal numeral system
A numeral system (or system of numeration) is a writing system
A writing system is a method of visually representing verbal communication
Communication (from Latin ''communicare'', meaning "to share") is t ...

see below for a compact way to codify ternary using nonary and septemvigesimal
There are many different numeral systems, that is, Writing system, writing systems for expressing numbers.
By culture / time period
By type of notation
Numeral systems are classified here as to whether they use positional notation (also known ...

.
As for rational number
In mathematics, a rational number is a number that can be expressed as the quotient or fraction (mathematics), fraction of two integers, a numerator and a non-zero denominator . For example, is a rational number, as is every integer (e.g. ) ...

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 is not a prime
A prime number (or a prime) is a natural number greater than 1 that is not a Product (mathematics), 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 ...

factor
FACTOR (the Foundation to Assist Canadian Talent on Records) is a private non-profit organization "dedicated to providing assistance toward the growth and development of the Music of Canada, Canadian music industry".
FACTOR was founded in 1982 by r ...

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) orseptemvigesimal
There are many different numeral systems, that is, Writing system, writing systems for expressing numbers.
By culture / time period
By type of notation
Numeral systems are classified here as to whether they use positional notation (also known ...

(base 27, each digit is three ternary digits) can be used for compact representation of ternary, similar to how octal
The octal numeral system, or oct for short, is the radix, base-8 number system, and uses the Numerical digit, digits 0 to 7, that is to say 10 represents 8 in decimal and 100 represents 64 in decimal. However, English uses a Base 10, base-10 num ...

and hexadecimal
In mathematics and computing, the hexadecimal (also base 16 or hex) numeral system is a Numeral system#Positional systems in detail, positional numeral system that represents numbers using a radix (base) of 16. Unlike the decimal system repres ...

systems are used in place of binary
Binary may refer to:
Science and technology
Mathematics
* Binary number
In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: ty ...

.
Practical usage

In certain analog logic, the state of the circuit is often expressed ternary. This is most commonly seen inCMOS
Complementary metal–oxide–semiconductor (CMOS, pronounced "see-moss"), also known as complementary-symmetry metal–oxide–semiconductor (COS-MOS), is a type of metal–oxide–semiconductor field-effect transistor
The metal–oxide–se ...

circuits, and also in transistor–transistor logic
Transistor–transistor logic (TTL) is a logic family
In computer engineering
Computer engineering (CoE or CpE) is a branch of engineering
Engineering is the use of scientific method, scientific principles to design and build machine ...

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 is for defensive statistics in American baseball
Baseball is a bat-and-ball gameBat-and-ball may refer to:
*Bat-and-ball games
Bat-and-ball games (or safe haven games) are field games played by two opposing teams, in which the action starts when the defending team throws a ball at ...

(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
Baseball is a bat-and-ball games, bat-and-ball game played between two opposing teams who take turns batting (baseball), batting and fielding. The game proceeds when a player on the fielding team (baseball), fielding team, ca ...

column for that game would be listed as 3.2, the equivalent of (which is sometimes used as in 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 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 remarkable and deep properties. It was discovered in 1874 by Henry John Stephen Smith and introduced by German mathematician Georg Cantor in 188 ...

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 nonzero 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 economyThe radix economy of a number in a particular base (or radix) is the number of digit (math), digits needed to express it in that base, multiplied by the base (the number of possible values each digit could have). This is one of various proposals that ...

, followed closely by binary
Binary may refer to:
Science and technology
Mathematics
* Binary number
In mathematics and digital electronics, a binary number is a number expressed in the base-2 numeral system or binary numeral system, which uses only two symbols: ty ...

and quaternary
The Quaternary ( ) is the current and most recent of the three period (geology), periods of the Cenozoic era (geology), Era in the geologic time scale of the International Commission on Stratigraphy (ICS). It follows the Neogene Period and spans ...

. This is due to its proximity to ''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 representationA redundant binary representation (RBR) is a numeral system
A numeral system (or system of numeration) is a writing system
A writing system is a method of visually representing verbal communication
Communication (from Latin ''communicar ...

called a binary signed-digit number system, a form of signed-digit representation
In mathematical notation
Mathematics (from Ancient Greek, Greek: ) includes the study of such topics as quantity (number theory), mathematical structure, structure (algebra), space (geometry), and calculus, change (mathematical analysis, ana ...

, 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 bits used to encode each trit. BCT encoding is analogous tobinary-coded decimal
In computing and electronics, electronic systems, binary-coded decimal (BCD) is a class of Binary numeral system, binary encodings of decimal numbers where each numerical digit, digit is represented by a fixed number of bits, usually four or ei ...

(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 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 performed by th ...

. A library of C code supporting BCT arithmetic is available.
Tryte

Someternary computer
A ternary computer (also called trinary computer) is a computer that uses ternary logic (three possible values) instead of the more popular Binary number, binary system ("Base 2") in its calculations.
Types of states
Ternary computing deals with th ...

s such as the Setun
Setun (russian: Сетунь) was a computer developed in 1958 at Moscow State University
Moscow State University (MSU; russian: Московский государственный университет имени М. В. Ломоносова, ...

defined a tryte to be six trits or approximately 9.5 bit
The bit is a basic unit of information in computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithm
of an algorithm (Euclid's algo ...

s (holding more information than the ''de facto'' byte
The byte is a unit of digital information that most commonly consists of eight bit
The bit is a basic unit of information in computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It ...

).
See also

*Ternary logic
In logic
Logic (from Ancient Greek, Greek: grc, wikt:λογική, λογική, label=none, lit=possessed of reason, intellectual, dialectical, argumentative, translit=logikḗ)Also related to (''logos''), "word, thought, idea, argument, a ...

* Tai Xuan Jing
The text ''Tài Xuán Jīng'' ("Canon of Supreme Mystery", ) was composed by the Confucian writer Yang Xiong (53 BCE-18 CE). The first draft of this work was completed in 2 BCE (in the decade before the fall of the Western Han dynasty). During t ...

* Setun
Setun (russian: Сетунь) was a computer developed in 1958 at Moscow State University
Moscow State University (MSU; russian: Московский государственный университет имени М. В. Ломоносова, ...

, a ternary computer
A ternary computer (also called trinary computer) is a computer that uses ternary logic (three possible values) instead of the more popular Binary number, binary system ("Base 2") in its calculations.
Types of states
Ternary computing deals with th ...

* Qutrit
A qutrit (or quantum trit) is a unit of quantum information
Quantum information is the information of the state of a quantum system. It is the basic entity of study in quantum information theory, and can be manipulated using quantum informat ...

* Ternary floating point
References

Further reading

*External links

Ternary Arithmetic

Ternary Base Conversion

ncludes fractional part, from Maths Is Fun

Gideon Frieder's replacement ternary numeral system

{{DEFAULTSORT:Ternary Numeral System Computer arithmetic Positional numeral systems Ternary computers