The unary numeral system is the simplest numeral system to represent
natural numbers: to represent a number ''N'', a symbol representing 1 is repeated ''N'' times.
In the unary system, the number
0 (zero) is represented by the
empty string, that is, the absence of a symbol. Numbers 1, 2, 3, 4, 5, 6, ... are represented in unary as 1, 11, 111, 1111, 11111, 111111, ...
Unary is a
bijective numeral system. However, because the value of a digit does not depend on its position, it is not a form of
positional notation
Positional notation (or place-value notation, or positional numeral system) usually denotes the extension to any base of the Hindu–Arabic numeral system (or decimal system). More generally, a positional system is a numeral system in which the ...
, and it is unclear whether it would be appropriate to say that it has a
base (or "radix") of
1, as it behaves differently from all other bases.
The use of
tally marks in counting is an application of the unary numeral system. For example, using the tally mark | (𝍷), the number 3 is represented as |||. In
East Asian cultures, the number 3 is represented as
三, a character drawn with three strokes. (One and two are represented similarly.) In China and Japan, the character ćŁ, drawn with 5 strokes, is sometimes used to represent 5 as a tally.
Unary numbers should be distinguished from
repunits, which are also written as sequences of ones but have their usual
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 of the Hindu–Arabic numeral ...
numerical interpretation.
Operations
Addition
Addition (usually signified by the Plus and minus signs#Plus sign, plus symbol ) is one of the four basic Operation (mathematics), operations of arithmetic, the other three being subtraction, multiplication and Division (mathematics), division. ...
and
subtraction
Subtraction is an arithmetic operation that represents the operation of removing objects from a collection. Subtraction is signified by the minus sign, . For example, in the adjacent picture, there are peaches—meaning 5 peaches with 2 taken ...
are particularly simple in the unary system, as they involve little more than
string concatenation. The
Hamming weight or population count operation that counts the number of nonzero bits in a sequence of binary values may also be interpreted as a conversion from unary to
binary number
A binary number is a number expressed in the base-2 numeral system or binary numeral system, a method of mathematical expression which uses only two symbols: typically "0" (zero) and "1" ( one).
The base-2 numeral system is a positional notatio ...
s.
[.] However,
multiplication
Multiplication (often denoted by the cross symbol , by the mid-line dot operator , by juxtaposition, or, on computers, by an asterisk ) is one of the four elementary mathematical operations of arithmetic, with the other ones being additi ...
is more cumbersome and has often been used as a test case for the design of
Turing machines.
Complexity
Compared to standard
positional numeral systems
Positional notation (or place-value notation, or positional numeral system) usually denotes the extension to any base of the Hindu–Arabic numeral system (or decimal system). More generally, a positional system is a numeral system in which the ...
, the unary system is inconvenient and hence is not used in practice for large calculations. It occurs in some
decision problem descriptions in
theoretical computer science (e.g. some
P-complete problems), where it is used to "artificially" decrease the run-time or space requirements of a problem. For instance, the problem of
integer factorization
In number theory, integer factorization is the decomposition of a composite number into a product of smaller integers. If these factors are further restricted to prime numbers, the process is called prime factorization.
When the numbers are suf ...
is suspected to require more than a polynomial function of the length of the input as run-time if the input is given in
binary, but it only needs linear runtime if the input is presented in unary. However, this is potentially misleading. Using a unary input is slower for any given number, not faster; the distinction is that a binary (or larger base) input is proportional to the base 2 (or larger base) logarithm of the number while unary input is proportional to the number itself. Therefore, while the run-time and space requirement in unary looks better as function of the input size, it does not represent a more efficient solution.
In
computational complexity theory, unary numbering is used to distinguish
strongly NP-complete In computational complexity, strong NP-completeness is a property of computational problems that is a special case of NP-completeness. A general computational problem may have numerical parameters. For example, the input to the bin packing problem ...
problems from problems that are
NP-complete but not strongly NP-complete. A problem in which the input includes some numerical parameters is strongly NP-complete if it remains NP-complete even when the size of the input is made artificially larger by representing the parameters in unary. For such a problem, there exist hard instances for which all parameter values are at most polynomially large.
Applications
Unary numbering is used as part of some data compression algorithms such as
Golomb coding. It also forms the basis for the
Peano axioms for formalizing arithmetic within
mathematical logic.
A form of unary notation called
Church encoding is used to represent numbers within
lambda calculus
Lambda calculus (also written as ''λ''-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation ...
.
[.]
See also
*
Unary coding
*
One-hot encoding
In digital circuits and machine learning, a one-hot is a group of Bit, bits among which the legal combinations of values are only those with a single high (1) bit and all the others low (0). A similar implementation in which all bits are '1' exc ...
References
External links
* {{OEIS el, sequencenumber=A000042, name=Unary representation of natural numbers
Numeral systems
1 (number)
Elementary mathematics
Coding theory
Formal languages