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

bartc bartc at freeuk.com
Mon Aug 24 01:04:37 CEST 2009


"Scott David Daniels" <Scott.Daniels at Acm.Org> wrote in message 
news:kN2dnSZR5b0BWAzXnZ2dnUVZ_s-dnZ2d at pdx.net...
> James Harris wrote:...
>> Another option:
>>
>>   0.(2:1011), 0.(8:7621), 0.(16:c26b)
>>
>> where the three characters "0.(" begin the sequence.
>>
>> Comments? Improvements?
>
> I did a little interpreter where non-base 10 numbers
> (up to base 36) were:
>
>     .7.100   == 64  (octal)
>     .9.100   == 100 (decimal)
>     .F.100   == 256 (hexadecimal)
>     .1.100   == 4   (binary)
>     .3.100   == 9   (trinary)
>     .Z.100   == 46656 (base 36)
> Advantages:
> Tokenizer can recognize chunks easily.
> Not visually too confusing,
> No issue of what base the base indicator is expressed in.

It can be assumed however that .9. isn't in binary?

That's a neat idea. But an even simpler scheme might be:

.octal.100
.decimal.100
.hex.100
.binary.100
.trinary.100

until it gets to this anyway:

.thiryseximal.100

-- 
Bartc 




More information about the Python-list mailing list