Hacker News new | ask | show | jobs
by mturmon 4053 days ago
On the contrary, unary numbers are a well-defined concept (http://en.wikipedia.org/wiki/Unary_numeral_system).

Unary numbers are perfectly commensurate with binary, decimal, octal, etc., numbers. In binary, you write

  B2 B1 B0
to mean the number:

  B2 * 2^2 + B1 * 2^1 + B0 * 2^0.
The same thing applies to unary numbers, just note that 1^n = 1 for every n, so writing:

  B2 B1 B0
means:

  B2 * 1^2 + B1 * 1^1 + B0 * 1^0 = B2 + B1 + B0, 
or, in other words, add the tally marks to get the number.
3 comments

Unary is a well defined concept, but it's not "base 1".

Or if you don't want to argue about the definition of base, at the very least it doesn't have any of the properties other base systems have.

A number in any base system can be thought of as an infinite string of zeros, followed by the digits. "1" is just a convenience, it could also be written "0000000001", or "0000...0001".

And then you can extend it to decimals, and have an infinite string of zeros after the decimal point. You can't have decimals in unary.

In other words it isn't necessary to store any additional information on how many symbols you need. The symbols are fixed, you just choose what state they are in.

Unary "cheats" by using a meaningless symbol and passing all the information in the number of times the symbol is written.

All the algorithms for adding numbers, dividing, subtraction, etc, can be generalized to work in any base. But not unary. Unary requires entirely different algorithms because it's not a base number system.

The formulas for converting between two bases work for any base system except unary. The formulas for measuring the number of digits you need to represent a number work for any base system except unary.

It's just an entirely different system of representing numbers. It's more similar to Roman numerals.

Unary representation differs from better bases in one very important regard: a base-n representation of a number uses n symbols, and you write the number as the coefficients of a power series in n. The n symbols you use are the natural numbers m such that 0 <= m < n.

But in a unary representation, the only number you could represent that way is 0. Instead, a unary system uses as coefficients the natural numbers m such that 0 < m <= 1. An immediate consequence is that there's no way to represent zero.

(In "unary-style" binary, you'd count like this: 1, 2, 11, 12, 21, 22, 111, 112... . The constraint that none of your coefficients can be zero (because it doesn't exist) makes the representation unique. If you're willing to use infinite representations along with finite ones, you could then represent zero in two's complement as ...111112, that is, one more than -1.)

Yes, thanks for the qualification regarding zero...the extension to the "base-1 case" is not as simple as I made it sound. Point taken.
you are assuming the lack of a digit is a digit. didn't you just made a way to add zero on base 1?

from the "base" definition on wikipedia: "In mathematical numeral systems, the radix or base is the number of unique digits, including zero."

Hmm, the original comment of yours, to which I replied, was rather different than the one there now.