Numeric literals in other than base 10 - was Annoying octal notation
cri at tiac.net
Sun Aug 23 05:38:59 CEST 2009
On Sat, 22 Aug 2009 14:54:41 -0700 (PDT), James Harris
<james.harris.1 at googlemail.com> wrote:
>On 22 Aug, 10:27, David <71da... at libero.it> wrote:
>... (snipped a discussion on languages and other systems interpreting
>numbers with a leading zero as octal)
>> > Either hexadecimal should have been 0h or octal should
>> > have been 0t :=3D)
>> I have seen the use of Q/q instead in order to make it clearer. I still
>> prefer Smalltalk's 16rFF and 8r377.
>> Two interesting options. In a project I have on I have also considered
>> using 0q as indicating octal. I maybe saw it used once somewhere else
>> but I have no idea where. 0t was a second choice and 0c third choice
>> (the other letters of oct). 0o should NOT be used for obvious reasons.
>> So you are saying that Smalltalk has <base in decimal>r<number> where
>> r is presumably for radix? That's maybe best of all. It preserves the
>> syntactic requirement of starting a number with a digit and seems to
>> have greatest flexibility. Not sure how good it looks but it's
>> certainly not bad.
I opine that a letter is better; special characters are a
valuable piece of real estate. However for floating point you
need at least three letters because a floating point number has
three parts: the fixed point point, the exponent base, and the
exponent. Now we can represent the radices of the individual
parts with the 'r'scheme, e.g., 2r101001, but we need separate
letters to designate the exponent base and the exponent. B and E
are the obvious choices, though we want to be careful about a
confusion with 'b' in hex. For example, using 'R',
is 20.1 in trinary (6 1/3) times 2**172 (hex ac).
I grant that this example looks a bit gobbledegookish, but normal
usage would be much simpler. The notation doesn't handle
balanced trinary; however I opine that balanced trinary requires
Richard Harter, cri at tiac.net
No one asks if a tree falls in the forest
if there is no one there to see it fall.
More information about the Python-list