Re: Numeric Literals (Summary 2)

[email protected] (Michael Lazzaro) Wed, 20 Nov 2002 10:31:06 -0800
Newsgroups perl.perl6.documentation
Message-ID <[email protected]>
On Tuesday, November 19, 2002, at 10:26  PM, Dave Storrs wrote:
> I would assume that 0B0110, 0C0123, and 0X00FF are all equivalent to
> the forms with lower-case base markers, right?

Huh, dunno.  Let's ask for a ruling on that.


>>     -0xff       # ok
>>     -0x00ff     # ok
> Are these two identical?

Yep.

> Is 0x-ff an error?  (I would say yes.)

Yes!

>>     0x_ff       # ok
>
> Wait a minute...the rule is that underscore can only appear between
> digits.  Here, the 'x' is not a digit, it is a base marker.
> Therefore, shouldn't this be an error?

Oops, yes.  Sorry.  Though we could probably allow it without 
ambiguity, if people wanted it.  Same with 1.234_e_5.

> The more I think on it, the more it seems like the negative sign
> should really go to the right of the colon (20:-1GJ)...otherwise, it
> really does look like you're using a negative radix (is that even
> possible?).  I realize this is out of step with the traditional -0xff,
> but it still seems like The Right Thing to me...what do other people
> think?

Larry said -20:1GJ, because (paraphrasing) the '-' is a unary operator 
meaning "negate", not a part of the literal number itself.  So you're 
specifying the number 20:1GJ, then negating it.


>>     62:zZ       # base 62 (?)
>>     62:z.Z      # base 62 (identical?)
>>     62:z_Z      # base 62 (identical?)
>>     62:Zz       # base 62 (not identical?)

Yes, that part shouldn't be in there anymore, we indeed nixed it.  
Can't use letters with radix > 36, have to use the coloned form.


>>    (radix 33-RADIX_MAX)
>>
>>    256:0.253.254.255   # base 256
>>    256:0_253_254_255   # base 256
>
> Are these two intended to be identical or not?  I expect not...the
> first should be a 4 digit number and the second a 10 digit number.

Yes, they're very different.

I'll post a follow up with all the corrections.

MikeL