Re: Numeric Literals (Summary 4)

[email protected] (Michael Lazzaro) Fri, 22 Nov 2002 09:43:52 -0800
Newsgroups perl.perl6.documentation
Message-ID <[email protected]>
On Friday, November 22, 2002, at 03:31  AM, Anton Berezin wrote:
> This:
>
>> - radix > 36, only colon form is allowed, not alpha digits
>
> implies that this:
>
>>   256#0_253_254_255   # base 256, NOT identical!
>
> is actually not allowed, no?

Ick, good point.  In theory, the second of those was supposed to mean:

     256#0253254255

but while all of those are valid digits in radix 256, the # syntax 
doesn't _allow_ digits in radix > 36, only integer representations of 
digits.

So I believe you are correct.  The second should give a syntax error, 
because 256# is looking for colon-separated integers, _not_ 
alphanumeric digits, and the value 0253254255 is > 255 (the max digit 
size of base 256).

So we have:

     16#00ff       # OK, == 0xff
     16#00_ff      # OK, == 0xff
     16#5          # OK, == 0x05
     16#f          # OK, == 0x0f
     16#15         # OK, == 0x15
     16#0:15       # OK, == 0x0f
     16#0:0:15:15  # OK, == 0x00ff
     16#0:0:f:f    # WRONG, colon style uses only decimal integers

     256#05                # OK, == 256#0:05
     256#0_5               # WRONG, 05 is one "digit", not two
     256#f                 # WRONG, (would be 256#0:f)
     256#1234              # WRONG, 1234 > max digit (255)
     256#12_34             # WRONG, 1234 > max digit (255)
     256#0:253:254:255     # OK
     256#0:fd:fe:ff        # WRONG
     256#0:0xfd:0xfe:0xff  # WRONG

I'll revise.

MikeL