Numeric literals in other than base 10 - was Annoying octal notation

Mensanator mensanator at
Tue Aug 25 07:27:51 CEST 2009

On Aug 24, 8:21�pm, Mel <mwil... at> wrote:
> Mensanator wrote:
> [ ... ]
> >> If you want your data file to have values entered in hex, or oct, or even
> >> unary (1=one, 11=two, 111=three, 1111=four...) you can.
> > Unary? I think you'll find that Standard Positional Number
> > Systems are not defined for radix 1.
> It has to be tweaked. �If the only digit you have is 0 then your numbers
> take the form
> 0*1 + 0*1**2 + 0*1**3 ...
> and every number has an infinitely long representation. �If you cheat and
> take a 1 digit instead then it becomes workable.

Not really. If your single digit is one, you still have
an infinitely long representation only instead of every
position being zero, every position is one.

So either the only number that can be represented is 0,
or the only number that can be represented is infinity.
No amount of tweaking can fix this.

So, to use radix 1, you have to abandon the concept
of "Standard" (contains a 0) AND abandon "Positional"
(infinitely long representation). It's all in TAOCP
by Knuth if you want to get it straight.

You can have a radix 1 number system, but is meaningless
to speak of "unary" in the same context as hex, decimal,
octal & binary.

> � � � � Mel.

More information about the Python-list mailing list