How to write zero in the unary numeral system

12.8k Views Asked by At
  • In the decimal system: $...-3, -2, -1, 0, 1, 2, 3...$
  • In the binary system: $...-11, -10, -1, 0, 1, 10, 11...$
  • In the unary system: $-111, -11, -1, \text{ ??? }, 1, 11, 111...$

I was only able to find a related question but none with an answer so far:

unary numbers: base-1 numeral system

11

There are 11 best solutions below

1
On BEST ANSWER

I was in Spain a couple of weeks ago, more precisely in Salamanca, which as you know has one of the oldest universities in Europe. I always take advantage of my travels to search for old books of mathematics. In this case, in a quite small old library close to the cathedral I found a book of mids XIX century. As I am not proficient in Spanish, with the help of a friend I translated the part talking about number representation.

The author talked about an ancient Moorish way of representing natural numbers in a decimal system, using a special symbol for 10. He uses the letter “D” to do so, in part because it is like a “1” and a “0” put together, in part because “D” is the beginning of “Diez” (ten in Spanish) – and I guess many ancient typesets lacked special symbols.

So I found curious the way of representing natural numbers in this decimal system:

1,2,3,….    …, 8, 9, D,
11,12,13…   …, 18,19,1D,
21,22,23…   …, 28,29,2D,
…
91,92,93…   …, 98,99,9D
D1,D2,D3…   …, D8,D9,DD
111,112,113…

This is a valid representation of all natural quantities, because there is one and only one representation for every quantity. For instance,

(4D8)D = (508)10
(DDD)D= (1110)10

The numbers not containing any "D" represent exactly the same quantity in both systems.

This author pointed out that this was the way that numbers were written anciently in a decimal system before the introduction of the “0” for representing quantities. He did not describe any historical facts -he talks about the Moors but maybe he was wrong-, but thinking about the way Egyptians used to represent numbers in a decimal system, they had special symbols for powers of 10, but the symbol for Zero (nfr) was never used as a symbol to write other numbers. So the author’s explanation makes sense.

Then I understood that one thing is having a symbol for Zero for operations and another thing is using that symbol to represent numbers. The question is,

If Zero is not a natural number, why do we introduce it inside the representation of them? If we have the set of natural numbers, and we want to have a decimal representation, in a pure natural representation we should not introduce an element we do not have. So for example, lets accept that we have powers of ten represented as Di. Then

(703)10 = 7 x D² + 0 (???) x D + 3 * 1

What is that ‘0’ element?

Then, extending this way of representing numbers to other systems, we have for example:

Octal: 1,2,3,4,5,6,7,8,11,12,13,14,15,16,17,18,21,22…
Binary: 1,2,11,12,21,22,111,112,121,122,211,212,221,222…
Unary: 1,11,111,1111,1111…

The conclusion is: The unary system is totally valid.

And as a side advantage, with this system we use less digits. For instance, with the normal binary system we can count up to (111)2= 7, while with this other binary system we can count up to (222)2= 14.

Of course there are advantages of using the Zero for representing natural numbers, but this led us to a confusion, making some people think -as we could see in some answers- that the unary system was not a valid system, or that Zero could be represented as a blank. It is indeed a valid system, and for sure the most ancient -at least it has been proved to be 20000 years old. And the answer to this question is that Zero in the unary system is the same as in any other system, something introduced not for representing quantities but as an element of more complex mathematics -as in algebraic structures like groups or rings, or in set theory, as the cardinality of the empty set.

18
On

You do something like this:

Sneaky, no?

"Unary" is just a tally-mark system, not a really full-fledged numeral system. You represent Zero by not representing any quantity at all.

One Apple: |

Two Apples: ||

No Apples:

And that's basically it. Putting any other symbol on the system to represent a Zero makes it a binary system.


In the comments, Joshua talks about head-tail delimiters for unary systems. You can use head-tail delimiters to make the zero-quantity evident or to separate groups of numbers.

For example, one could write "||", "|||", and "" to represent 2, 3 and 0. In this case, the quotes aren't part of the numbers but they help us visualize where the number starts or ends and they make the 0-value visible.

Keep in mind that "unary" isn't really a numeral system with the same representative capabilities of binary, hex, etc. For it to be used properly as a mathematical tool you end up needing to hack it a bit adding some other symbols. At that point you can just use something else that can represent your problem on a more practical way.

12
On

In fact, there is no "unary" number system that is the analog of fixed-radix systems (e.g., base $2$, base $10$, etc). A radix, by definition, is a number greater than $1$.

Your "unary" system is really nothing more than tally marks. So zero would be represented by the absence of any symbol. These are really strings, not numbers. You can't add them using column addition. So you really have

$$-3_{10} = “-111_1”$$ $$-2_{10} = “-11_1”$$ $$-1_{10} = “-1_1”$$ $$0_{10} = “”$$ $$1_{10} = “1_1”$$ $$2_{10} = “11_1”$$ $$3_{10} = “111_1”$$

0
On

The "unary" system is more closely related to Roman Numerals than to the decimal or binary system.

In every "$n$-ary" such as binary, ternary, octal, decimal, hexadecimal, and so forth, the digits are $0, 1, \ldots, n-1.$ If we applied that rule to unary, since $n-1 = 0$ the only digit would be $0$ itself, and zero would be the only number that could be written.

To construct a real "base $1$" system according to the same general principals as other base-$n$ systems is not useful. Therefore someone decided to use the name "unary" for the tally-mark system instead, that is, since it can only have one digit the digit would be $1$ and not $0.$ Not surprisingly, this number system cannot do everything that all the "regular" base-$n$ systems can do.

0
On

The notion of zero is a relatively recent one - see History of Zero . There is no zero in unary.

See Unary numeral system

6
On

This is more like a long comment.

In some sense, we actually denote $0$ "incorrectly" in the binary and decimal systems. Let me explain.

For each natural number $n$, define a function $$\#_n : \mathbb{N}^n \rightarrow \mathbb{N}$$ as follows:

$$\#_n(a) = \sum_{i=0}^{n-1} a_i 10^i$$

For example, we can think of $487$ as shorthand for the more formal $\#_3(7,8,4)$. The relevant "computation" in all its glorious details:

$$\#_3(7,8,4) = (7,8,4)_0 10^0+(7,8,4)_1 10^1+(7,8,4)_2 10^2 = 7 \cdot 10^0+8\cdot 10^1 +4 \cdot 10^2 = 487$$

Okay, lets now ask ourselves: what are the rules for normal forms? Surely a necessary condition for being a normal form is not having any $0$'s on the right, since they're redundant:

$$\#_{n+1}(a,0)= \sum_{i=0}^{n} (a,0)_i 10^i = (a,0)_n+\sum_{i=0}^{n-1} (a,0)_i 10^i = 0+\sum_{i=0}^{n-1} a_i 10^i = \#_n(a)$$

This suggests that $0$ is not in normal form, because that's really shorthand for $\#_1(0),$ which, due to the presence of redundant zeroes, isn't in normal form. The normal form for $0$ is actually $\#_0().$

Though honestly, I'm not too fussed :)

By the way, this kind of notation is actually pretty useful for doing computations. For example, suppose we're trying to find $67+58$. We can write something like this:

$$67+58 = [6,7]+[5,8] = [11,15] = [12,5] = [1,2,5] = 125$$

This is very similar to the high school method of writing the two numbers one above the other, and doing a sum for each column while "carrying" the overflow to the next column.

0
On

While I can see the argument that zero in unary 'should be' represented by "" (i.e nothing there), I would counter-argue that zero should be represented the same way in any other number system - i.e by "0" - with the proviso that one must have -either- that symbol -or- tally-marks, never both in the same expression. The entire point of introducing the special symbol "0" is to be able to visually indicate the presence of an absence (a rather paradoxical notion, actually).

1
On

I feel it is important to point out that there is no true unary system, in the sense that there needs to be some way of determining where a notation ends, and so that blank space or whatever else is used to indicate termination is actually functioning as a second symbol! This is very obvious if you think about how you could transmit arbitrarily large natural numbers to another person, such that the recipient knows when you are done transmitting. Informally, you cannot just use a fixed piece of paper or fixed length of time or fixed number of signals, since any bounded notation will only be able to represent a finite number of numbers. More formally, whatever medium you use must have at least two states, because if it only has one state then it cannot convey a single bit of information!

As others have pointed out, unary is just like tally marks, but it is wrong to assume that it uses only one symbol. When you read the tally marks, you stop when you reach a blank space, so actually there are two symbols, namely the tally mark and the blank space!

Explicitly (with "|" denoting each tally mark and "□" denoting the first blank space):

$3 \mapsto$ |||□

$2 \mapsto$ ||□

$1 \mapsto$ |□

$0 \mapsto$

As you can see, the actual fact is that unary uses two symbols and is very inefficient. A natural next question is then whether binary in fact requires three symbols. Using the standard binary encoding, yes we need a termination symbol as before.

However, there are binary prefix-free codes that can easily encode arbitrarily large natural numbers such that you know when the notation terminates without needing a third symbol. One basic method is to use unary (since we have two symbols) to encode the length of the binary representation, and then put the binary representation after that:

$3 \mapsto$ 11011

$2 \mapsto$ 11010

$1 \mapsto$ 101

$0 \mapsto$ 0

Note that we can save a bit by dropping the "1" in front of the binary representation (except for $0$). And if you think using unary at the start is wasteful, you can recursively apply this strategy one or more times, yielding one of the many universal codes.

2
On

To understand the problem in the "unary" system we have a look on the ternary system first. Normally numeral systems use digits $\{0, 1, ... (N-1)\}$ so the terneray system uses the digits $\{0, 1, 2\}$.

However there is the so-called "symmetric" ternary system which has been used for some computers in the 1960s. This system used the digits $\{-1, 0, 1\}$ instead.

You might also define that "your" ternary system uses the digits $\{1, 2, 3\}$ instead of $\{0, 1, 2\}$ (although this makes no sense). Doing so would allow you to write any positive integer - but not the number zero. Here the numbers from 12 (decimal) to 1 (downwards) in that system:

... 33, 32, 31, 23, 22, 21, 13, 12, 11, 3, 2, 1, (can't write 0!)

By defining an "unary system" using the digit $1$ (instead of $0$) this is what you are doing!

Just like in the non-standard ternary system using digits $\{1, 2, 3\}$ you can write any positive integer but not the number zero.

Using the "normal" "unary system" would allow you to write the number zero - but no other numbers.

4
On

Simple:

0 = 1
1 = 11
2 = 111
3 = 1111

Just have every number use one more tally mark than its value. As a programmer, I would call this zero-based unary.

1
On

@user21820 and @paul-chernoch I know, it's very old thread, but your solutions are the same as mine, and I am happy that someone thought like me. Zero-based unary - very nice name for this solution. I called this solution box-based, why??? As @user21829 wrote: 3↦|||□ 2↦||□ 1↦|□ 0↦□ If we have boxes, we can put any amount of something in them. In unary usually we put 1 thing in each box, but we can put 5 or 10, than count all of boxes and multiply by number of boxes. We also have a lot of empty boxes, which we can use, why don't use it in last (place of ones) place??? This way we can modify @user21829 solution and write all numbers like in decimal:

A↦(1) - box with $1$

A↦(1) - box with $1$

A↦(1) - box with $1$

A↦(0) - empty box

$$(AAAA)1 = 1+1+1+0 = 3.$$

In this way, I wrote a program that can convert numbers to mononomial and polynomial numbering systems. The unary system was a big challenge for me, but I succeeded. The program also performs basic calculations on numbers up to $2147483647$ digits without rounding.

MikiCalculator