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

Scott David Daniels Scott.Daniels at Acm.Org
Mon Aug 24 18:18:20 CEST 2009


Piet van Oostrum wrote:
>>>>>> 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.
Obviously I started with a different set of examples and edited after 
starting to make a table that could be interpretted in each base.  After
doing that, I forgot to double check, and lo and behold .F.1000 = 46656,
while .F.100 = 1296.  Since it has been decades since I've had access
to that interpreter, this is all from memory.

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list