36
  • 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

Hern
  • 3
Josi
  • 507
  • 2
    1-1 or 11-11 or 111-111, etc – Yuriy S Feb 23 '17 at 13:58
  • 11
    If you have a definition, use it; if not, make it up. The definition of unary is of so little mathematical importance that I doubt you will find a meaningful consensus. I agree with the suggestion of using “$0$”, or even –not suggested yet as I write– “$-$”. – PJTraill Feb 23 '17 at 21:15
  • 1
    The unary system described by you is not a valid "positional number system" (which is what decimal and binary are). A blank is probably the most reasonable choice, but don't feel taken back by the difference in approach. – Euro Micelli Feb 24 '17 at 06:24
  • Note that in $x$-al system you have $x$-its from $0$ to largest integer less than $x$. This makes your proposed unary system quite odd. – skyking Feb 24 '17 at 07:40
  • @skyking: It's definitely not a base-$1$ system, but conventionally it's called "unary" anyway. Many textbooks on Turing machines also use this unary representation for ease of exposition, but necessarily the tape must support at least two 'symbols' (each cell can be blank or non-blank), for pretty much the reason explained in my answer. – user21820 Feb 24 '17 at 07:48

11 Answers11

60

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.

T. Sar
  • 758
  • 7
    Any complete use of unary has head-tail marking or list-separator marking, which completes this answer. – Joshua Feb 23 '17 at 16:18
  • 22
    Before I finished reading the whole text I was wondering why the spoiler quote wasn't working! – Fine Man Feb 24 '17 at 02:28
  • As I state in my answer, putting a tally mark and not putting a tally mark are essentially two symbols, and there is no truly unary system. – user21820 Feb 24 '17 at 07:42
  • Surely you could have defined it as well so that zero is | and one is ||, and so on – minseong Feb 24 '17 at 08:04
  • @user21820 That's a matter of interpretation. Unary isn't a good - or complete - number system. it's just a counting mechanism, and thus I put the quotes when dealing with it's name. I agree that it isn't really a true number system. – T. Sar Feb 24 '17 at 11:18
  • @TSar: My point was that your phrasing in "Putting any other symbol to represent a Zero makes it a binary system." suggests that unary uses only one symbol, which is naturally misleading to people who are not aware of the symbolic role of blank space... – user21820 Feb 24 '17 at 11:29
  • @user21820 "no symbol" isn't a symbol. Unary doesn't support zero in the sense of other systems - it supports "not representing a quantity", which is a property of the textual context and not of the number system per se. For example, writting One Apple: 1, Two Apples: 2, No Apples: __ is equally valid on decimal or hex. That doesn't make "blank" a symbol on those systems. – T. Sar Feb 24 '17 at 11:35
  • @TSar: Frankly, I think you have the same misunderstanding as many people concerning coding systems. Please read my answer to see why the blank space is no different from a symbol. If you have any queries after that, I'll be glad to answer. – user21820 Feb 24 '17 at 11:37
  • @user21820 Isn't a matter of misunderstanding as much as forcing this system to be something it isn't. This isn't a complete, full fledged numeral system that can support zeroes naturally. It is just tally-marks, nothing more. Everything else is just putting lipstick on a pig. – T. Sar Feb 24 '17 at 11:40
  • @user21820 I take the Database approach. NULL isn't a symbol, isn't a letter, isn't a number. It's nothing. It's the absence of information. My Unary grammar is defined as ["|"]+. So, the NULL information isn't a valid number in this system and the textual context makes it represent 0, the same way blank can be used to represent 0 on a decimal-using form. – T. Sar Feb 24 '17 at 11:47
  • I never said it's more than tally marks, but tally marks only work if you can put a blank space after. Unary, like tally marks, need that to even represent numbers. Just because it is a blank instead of some other symbol does not make it not a symbol, mathematically. And your database approach is in fact contrary to your position; you can't store literally nothing in the actual database, it is actually stored as some representation, and the semantics of null that you wish to interpret it with does not change the fact that it is symbolic. Anyway think whatever you like. – user21820 Feb 24 '17 at 11:51
  • @user21820 You can store literally nothing, and "nothing" is represented as null. That's the difference. But, oh, well, We have different approach to some stuff, it seems. Neither of us is incorrect, we just don't agree with each other. – T. Sar Feb 24 '17 at 11:55
  • @TSar: That's false. Everything stored in databases is represented by bits (logically, before storage on physical media), and there is no such thing as storing nothing. Whether you choose to represent "nothing" (or "unknown" or "undefined" or whatever else) by the database 'value' null is irrelevant to the fact that null is a symbolic reference and not literally nothing. I don't know why you cannot understand this point, because even your statement in your own post that the quotes are there to show where the unary representation starts and ends directly support my answer. – user21820 Feb 24 '17 at 12:01
  • Now I'm not saying that your viewpoint is invalid when managing databases in real life, since you don't need to care about the way null is actually stored in the database internals. However this is Math SE and so the answer should be from the mathematically correct viewpoint. – user21820 Feb 24 '17 at 12:02
  • @user21820 The way of storing my nulls is irrelevant as much as the paper you write your calculations on. My database can store my nulls as "no bits" followed by the column terminator - something like ;; on a csv. There is no value, no bits there. But okay - I'll just disengage - if you think my answer is incorrect, feel free to downvote. You're not wrong, but I think you're being a little too radical regarding this whole thing. – T. Sar Feb 24 '17 at 12:05
  • 2
    Empty symbol is also a symbol ( if put in an appropriate place), so in fact your proposition is binary. – Widawensen Feb 25 '17 at 09:04
  • @Widawensen I would agree if I was proposing Unary as a full fledged number system. However, I'm letting it clear that it isn't a regular number system as DEC and HEX - it's just a name for tally marks. – T. Sar Mar 01 '17 at 11:05
  • @TSar O.k. So it is just a name... – Widawensen Mar 01 '17 at 11:07
22

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”$$

Aweygan
  • 23,232
MPW
  • 43,638
  • 13
    "There is no unary number system" - that is so true! a unary number system would only use $0$'s after all, e.g. $$000 = 0\cdot 1^2+0\cdot 1^1+0\cdot 1^0 = 0$$ – goblin GONE Feb 23 '17 at 15:21
  • 5
    And goblin's comment explains (in my opinion) why the radix of a standard base-$n$ system must be greater than $1.$ This may be presented as a definition, but it's not an arbitrary definition. – David K Feb 23 '17 at 18:13
  • 1
    It is indeed possible to define a columnar addition even in a hypothetical unary system (which is essentially a concatenation string). Here's what you do: take a carry over symbol each time you have to add two symbols and not down the base number of this system, which is essentially the symbol you have chosen. E.g. when adding | to ||, you would first add | and |, to get an overflow in youe base, then jot down the base symbol which is | and carry | ahead. In this manner you obtain ||| which is, as expected, |+||. – axolotl Feb 23 '17 at 19:10
  • 1
    @zakoda : That's not column addition. Column addition results in a single digit with a carry. It doesn't work the same way. Yes, you can pretend it's column addition with weird rules that don't apply with any other base, but it really isn't. In the end, you're just counting all the tally marks in every addend -- not column addition. – MPW Feb 23 '17 at 22:15
  • 1
    Wouldn't it be possible to define an unary system by shifting, so that $1$ and $-1$ represent $0$, and $11$ represent $1$, $-1111$ represent $-3$ and so on? – ClassicEndingMusic Feb 24 '17 at 00:06
  • @MPW I don't see why this "doesn't apply to any other base." In a base $B\geq2$, we do the same thing. We note down the exact amount of overflow w.r.t. our base and carry forward the nearest smaller multiple of the base to our overflown addition. Consider binary. When we add 1 and 1, we exhaust our symbols that can represent the number and hence encounter the base, 10. We then see how many numbers beyond our preliminary counting capacity did we overflow. In this case, 1, since the base must be written to compensate the lack of basic digits after 0 and 1. \n I think that this analogy works. – axolotl Feb 24 '17 at 05:16
  • 1
    @zakoda Try 1111+1111. By the way, we don't always carry when we encounter the base in unary--in unary, everything is the base, so if you always had to carry the base, addition would never terminate. – David K Feb 24 '17 at 09:05
  • @DavidK, if you're trying to point out a case where the aforementioned method doesn't work, then couod you elaborate? Because I'm arriving at 11111111 which is also what we would get if we concatenated the tally marks (or the ones) – axolotl Feb 24 '17 at 09:08
  • @zakoda Nobody said you can't add these numbers; concatenation is a fine algorithm for tally marks. The point is that "carrying" introduces a lot of unnecessary complexity here, unlike every actual place-value system where it is very helpful. – David K Feb 24 '17 at 09:13
  • 1
    @DavidK agreed. It was never my point that one should use columnar addition as suggested above for adding tally marks. I was just trying to demonstrate that it is not "impossible" or invalid, per se, in this base as MPW suggests in their answer. It is a perfectly valid addition algorithm also analogous to the "normal" bases of 2 and above. – axolotl Feb 24 '17 at 09:15
  • "A radix, by definition, is a number greater than $1$." not true, it's a number $r$ that meets the rule $|r|>1$ there are negative bases too. – EKons Aug 09 '17 at 17:44
  • However what happen with this 0(10) = 0(5) = 0(2)? the value zero must be represented with symbols of the alphabet, for this alphabet A={0} that represents all symbols for a unary system, 0(0) = 0(2) – Fabio Andrés Feb 18 '21 at 22:57
9

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.

David K
  • 98,388
8

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.

goblin GONE
  • 67,744
  • @MPW with reference to my comment on your answer, please also consider the way columnar addition is represented here. I think this is consistent with what I am trying to say. – axolotl Feb 24 '17 at 05:20
  • If I follow your answer: you define a collection of functions $#_n$, and then out of a sudden: "what are the rules for normal forms?" which follows by "Surely a necessary condition". First, it does not seem that you've defined what a normal form is in this particular context, which makes it hard to say what are the obvious statements about them. Second, $#_0()$ seems undefined, as by definition of $#_0$ it must call a zeroth element of its argument, and empty argument does not seem to have any elements at all. – SBF Feb 24 '17 at 11:54
  • @Ilya, note that $#_0 : \mathbb{R}^0 \rightarrow \mathbb{R},$ so a $0$-long list of inputs is actually correct. – goblin GONE Feb 24 '17 at 16:37
  • You're correct on that point – SBF Feb 24 '17 at 16:38
  • @Ilya, regarding normal forms, I don't actually know how to specify normal forms; my training is in classical set-theory, which mostly ignores computational issues. I guess to do it properly, I'd have to change the domain and codomain of the hash function(s) to $\mathbb{N}^n \rightarrow \mathbb{N}$, and then assert that an expression involving these functions, and only these functions, is in normal form iff firstly, there's no $0$'s on the right, and secondly, it's been completely "denested" so that e.g. $#_2(#_2(2,3),9)) = #_2(2,2,1)$. Something like that. Like I said, I don't know how... – goblin GONE Feb 24 '17 at 16:42
  • ... to really do this stuff formally. – goblin GONE Feb 24 '17 at 16:43
4

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).

PMar
  • 86
2

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.

user21820
  • 57,693
  • 9
  • 98
  • 256
  • Different perspective on the same thing: Truly single-symbol unary doesn't typecheck. (If succ : X, you can't actually form successors; if succ : X -> X, you lack the base case – there might be one infinite "number" if your universe permits, or else none at all.) – nobody Feb 24 '17 at 09:25
1

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

See Unary numeral system

1

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.

1

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.

Josi
  • 507
0

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

@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

TShiong
  • 1,257
Arduan
  • 1
  • 1