Unary system

from Wikipedia, the free encyclopedia
Beer mat with tally sheet

The unary system , colloquially also called beer mat notation , is a number system that has only one symbol with the value 1. So you can simply write down each number as a set of such symbols (usually vertical bars), e.g. B. the number 6 as ||||||.

Examples

One , two , three , four and five in unary notation
0:
1: |
4: ||||

In tally sheets, the individual digits are also grouped into groups of five digits each:

7: ||||||| or |||| ||
8: |||||||| or |||| |||
10: |||||||||| or |||| ||||

Practical use

The unary system is suitable for simple counting tasks, since a number is increased by 1 by simply adding another symbol. It is used e.g. B. as a tally , in which often every fifth line is drawn across the four previous ones for better readability. The resulting number is shown grouped in blocks of five, making it easier to understand.

In gastronomy, it is used as a beer mat notation to record the number of beers consumed on the consumer's beer mat in the form of a tally sheet.

In addition, the unary system is occasionally used in computer science , especially in theoretical computer science , e.g. B. as a way of displaying numbers on the tape of a Turing machine .

In contrast to place value systems such as the decimal or the dual / binary system , it is not possible in the unary system to represent non-whole numbers by setting a comma.

particularities

Because of some peculiarities of the representation of numbers in the unary system , this representation is useful for some considerations of theoretical computer science.

  • Only one character is required for representation. This simplifies the alphabet to be considered in calculations.
  • Characters have no position-dependent meaning. In the number 123 (decimal), 1 has the meaning of the hundreds, the 3 that of the ones. If you remove a digit, e.g. B. the 3, then a 12 remains. The 1 now has the meaning of the tens. This problem does not occur in the unary system. The meaning of the digits is therefore context-free.
  • Additions and subtractions are simplified (from the point of view of the notation, not from the point of view of the characters to be written). Two summands are added by simply writing the numbers one after the other. Example: 8 + 5 = 13 in the unary system is 11111111 + 11111 = 1111111111111. For comparison: in the decimal system you cannot write 8 + 5 = 85. In theoretical considerations, this property offers the advantage that the digits written once during an addition no longer have to be changed.
  • Intermediate storage of numbers in abstract machines is less necessary. Example: With the help of an abstract machine, e.g. B. a Turing machine are added. The machine has two input tapes on which the summands are written and which - similar to a computer keyboard - can only be read once, and an output tape which, similar to a printer, can only be written to. If the numbers are unary coded, the algorithm is simplified to: Copy the first input tape onto the output tape and then copy the second input tape onto the output tape. Read characters do not have to be temporarily stored and only need to be read once. The addition is context-free. In comparison, addition in the decimal system is considerably more complicated. For example, if we want to calculate 123 + 456 (= 579), both numbers must be read in completely and temporarily stored. This is the only way to determine that the 1 from 123 and the 4 from 456 have the same value and can therefore be added and the sum, here 5, is not changed upwards by adding the following digits.
  • A positive integer is equal to the number of digits it represents in the unary system. This quickly makes this representation unwieldy. Therefore the unary system has practical applications only for small numbers. It usually has a practical meaning where it has to be easy to increase the number by 1 without changing what has been written so far. Because of the high number of digits, the beer mat notation is generally more important for theoretical considerations of the theory of predictability .

See also