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

Piet van Oostrum piet at cs.uu.nl
Mon Aug 24 03:51:37 EDT 2009


>>>>> Scott David Daniels <Scott.Daniels at Acm.Org> (SDD) wrote:

>SDD> James Harris wrote:...
>>> Another option:
>>> 
>>> 0.(2:1011), 0.(8:7621), 0.(16:c26b)
>>> 
>>> where the three characters "0.(" begin the sequence.
>>> 
>>> Comments? Improvements?

>SDD> I did a little interpreter where non-base 10 numbers
>SDD> (up to base 36) were:

>SDD>     .7.100   == 64  (octal)
>SDD>     .9.100   == 100 (decimal)
>SDD>     .F.100   == 256 (hexadecimal)
>SDD>     .1.100   == 4   (binary)
>SDD>     .3.100   == 9   (trinary)
>SDD>     .Z.100   == 46656 (base 36)

I wonder how you wrote that interpreter, given that some answers are wrong.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list