[Python-Dev] Re: [Patches] [Patch #100752] Make atoi work for negative bases, a useful generalization

Guido van Rossum guido@beopen.com
Fri, 07 Jul 2000 09:38:39 -0500


> Built-in support for negative bases would encourage further use of Python
> in math research (specifically, representation theory). For reference,
> Mathematica recently added support for negative base conversions.
> 
> Negative bases allow the unique representation of both positive and
> negative integers without use of a sign. For example, "-3" in decimal 
> equals, in base -2, "1101" (-3 = 1*(-2)^3 + 1*(-2)^2 + 0*(-2)^1 + 1*(-2)^0).
> It has been suggested that this property makes negative bases a more natural
> representation for integers than positive bases. There is more detailed 
> information on the subject in The Art of Computer Programming Vol. 2.

Only a mathematician could call this "more natural"...

For most of us, this is difficult to understand (e.g. the suggestion
was made that int(s,x) == -int(s,-x), which isn't true) and there are
no practical uses.

As most of Python's users lack the sophistication to understand this,
I'd rather not introduce this patch -- when I see a negative base
somewhere, it's much more likely that it's a bug in the code than an
advanced use of negative bases...

That's a polite but firm -1.

--Guido van Rossum (home page: http://dinsdale.python.org/~guido/)