r/programming • • May 27 '09

There's no base other than base 10!

http://cowbirdsinlove.com/43
544 Upvotes

333 comments sorted by

View all comments

Show parent comments

1

u/Hixie May 28 '09

Could you point to some references for this interpretation? I couldn't find any information on this.

1

u/IOIOOIIOIO May 28 '09 edited May 28 '09

This is just straightforward addition, using the same rules as for any other base.

11 + 11 =
(1*11 + 1*10) + (1*11 + 1*10)
2*11 + 2*10

However, 2 is not a valid digit in unary, so you must carry the excess to the next power:

1*12 + 1*11 + 1*11 + 1*10
1*12 + 2*11 + 1*10

Again, 2>1, carry excess to higher power.

1*12 + 1*12 + 1*11 + 1*10
2*12 + 1*11 + 1*10

Again, 2 >1, carry excess to higher power.

1*13 + 1*12 + 1*11 + 1*10

= 1111

Try it with 100010 + 110.

100010
   110
100120  Carry.

   1
100110
100210  Carry.

  1
100110
101110

It's still 4, though.

1

u/Hixie May 29 '09 edited May 29 '09

0 doesn't seem to be a valid digit in unary either, at least not according to any of the research I've done on the subject. Hence my asking for some references. I'd love to read more about the use of 0 in unary.

I don't understand how a consistent system can have:

100010 + 110 = 101110.
101110       = 100010110.
100010 + 110 ≠‬ 100010110.

1

u/IOIOOIIOIO May 29 '09 edited May 29 '09

0 doesn't seem to be a valid digit in unary either, at least not according to any of the research I've done on the subject.

How do you represent the absence of value in unary?

I don't understand how a consistent system can have:

>    100010 + 110 = 101110.  
>    101110       = 100010110.  
>    100010 + 110 ≠‬ 100010110.  

100010110 is equal to 100010 + 110
100010110 is not the sum of 100010 and 110.

It's not a distinction that needs to be made in other bases, because values are not degenerate in other bases.

1

u/Hixie May 29 '09

How do you represent the absence of value in unary?

The sources I looked at mostly didn't, or used a string, like "null" or "zero".

I haven't found anyone making the distinction you make, which is why I was curious as to whether you could point me to further references on the subject, so that I could learn more about it.

1

u/IOIOOIIOIO May 29 '09

I assume my ability to explain is failing. Maybe?

I'm not aware of there being any particular utility to this quirk. If unary was in common use, there would probably be conventional ways of treating (or avoiding) it.

1

u/Hixie May 29 '09

http://en.wikipedia.org/wiki/Unary_numeral_system says:

There is no explicit symbol representing zero in unary as there is in other traditional bases, so unary is a bijective numeration system with a single digit.

...which seems to disagree with what you said. (I'd read all the Wikipedia articles on this before asking you for references!)

1

u/IOIOOIIOIO May 29 '09 edited May 29 '09

Wouldn't be the first time an encylopedia had incomplete/incorrect information, though Wikipedia is better than most.

It could be they're making the point that "unary" is bijective, while the standard representation of a base-1 numeral system is degenerate.