Unary numeral system

From Wikipedia, the free encyclopedia
Jump to: navigation, search

The unary numeral system is the bijective base-1 numeral system. It is the simplest numeral system to represent natural numbers:[1] in order to represent a number N, an arbitrarily chosen symbol representing 1 is repeated N times.

This system is used in tallying. For example, using the tally mark |, the number 3 is represented as |||. In East Asian cultures, the number three is represented as “”, a character that is drawn with three strokes.[2]


Addition and subtraction are particularly simple in the unary system, as they involve little more than string concatenation.[3] 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 numbers.[1] Multiplication and division are more cumbersome, however.


Compared to standard positional numeral systems, the unary system is inconvenient and 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 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.[4] But 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; so while the run-time and space requirement in unary looks better as function of the input size, it is a worse function of the number that the input represents.

In computational complexity theory, unary numbering is used to distinguish strongly NP-complete 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.[5]

Unary counting happens when you pour many equal amounts of fluid into the same cup and observe the height is the sum of the integer number of cups poured in. Unary is a linear sum. Turning pages in a book counts the width of the left and right sides of that book in unary in units of page width. If you searched through a dictionary in unary order, you would read all the pages 1 at a time and days later find the word you want. In radix/positional order, you find it exponentially faster using Binary search algorithm. You grab a thick block of pages and flip them all at once instead of unary order reading through each of them. Without the more direct branching, you would be unable to read that dictionary or Library catalog at the speed of millions or more words per second (minus the words you don't care about) and find your word and definition at practical speed.

A next deeper recursion away from unary numbers, like in Two's complement binary representation of integers in most computing hardware, is Floating point or Scientific notation which counts in units of digits of radix/positional numbers. Recursion 0 is unary, then digits, then digits of digits (scientific notation / floating point / exponential), then Superexponential, and so on.

A Tag system, in computing theory, for example Rule 110 which is capable of general computing while astronomically slow, computes in unary as a Queue. These layers of slowness build up recursively and only in a theoretical limit reach the practical computing we enjoy today which skip over those unary abstractions using numbers that refer to other numbers.


Unary is used as part of some data compression algorithms such as Golomb coding.[6]

Connection to number of fingers[edit]

The base/radix of a number system is unary counted within each digit.

Counting up to 10 fingers is unary and more intuitive than positional numbers like each hand has a base 6 digit (0-5 on one hand)*6 + (0-5 on other hand) or each of 6 fingers (the 3 easiest on each hand) as a base 2 digit for counting from 0 to 2^6-1 = 63 on your fingers. The repeated differences in size as powers of 10, especially 10^3 like megagram vs gigagram, in Metric system align with the ways of thinking resulting from having 10 fingers and unary counting with them. Hexadecimal (base 16) is a depth 4 recursion, and Octal and some uses of Byte as depth 3 recursion of Binary number but the world prefers to unary count in units of symmetric physical senses we have in fingers (an efficient reuse of Neurons connected to the fingers).

See also[edit]


  1. ^ a b Blaxell, David (1978), "Record linkage by bit pattern matching", in Hogben, David; Fife, Dennis W., Computer Science and Statistics--Tenth Annual Symposium on the Interface, NBS Special Publication 503, U.S. Department of Commerce / National Bureau of Standards, pp. 146–156 .
  2. ^ Woodruff, Charles E. (1909), "The evolution of modern numerals from ancient tally marks", American Mathematical Monthly 16 (8–9): 125–133, doi:10.2307/2970818, JSTOR 2970818 .
  3. ^ Sazonov, Vladimir Yu. (1995), "On feasible numbers", Logic and computational complexity (Indianapolis, IN, 1994), Lecture Notes in Comput. Sci. 960, Springer, Berlin, pp. 30–51, doi:10.1007/3-540-60178-3_78, ISBN 978-3-540-60178-4, MR 1449655 . See in particular p.  48.
  4. ^ Feigenbaum, Joan (Fall 2012), CPSC 468/568 HW1 Solution Set (PDF), Computer Science Department, Yale University, retrieved 2014-10-21 .
  5. ^ Garey, M. R.; Johnson, D. S. (1978), "'Strong' NP-completeness results: Motivation, examples, and implications", Journal of the ACM (New York, NY: ACM) 25 (3): 499–508, doi:10.1145/322077.322090, MR 478747 .
  6. ^ Golomb, S.W. (1966), "Run-length encodings", IEEE Transactions on Information Theory, IT-12 (3): 399–401, doi:10.1109/TIT.1966.1053907 .

External links[edit]