Numeric Literals (Summary)

[email protected] (Michael Lazzaro) Thu, 14 Nov 2002 10:28:38 -0800
Newsgroups perl.perl6.documentation
Message-ID <[email protected]>
W/ regards to numeric literals, here are a number of examples/proposals 
that we should verify the behavior of.  Anything I missed?

decimal:       (meaning?)
      123       # int 123
     0123       # int 123
     123.0      # num 123.0
     -123       # int -123

    0_1.2_3     # ok
    _01.23      # wrong
    01.23_      # wrong
    01_._23     # wrong?
    1__2        # wrong

exponential:
    -1.23e4     # num
    -1.23E4     # num (identical)

    1.23_e_4    # ok?

bin/oct/hex literals:

    0b0110      # bin
    0c0123      # oct
    0x00ff      # hex
    0x00fF      # hex, == 0x00ff
    0x00FF      # hex, == 0x00ff

    0xf_f       # ok
    0x_ff       # ok

explicit radix:

    20:1gk      # base 20
    20:1GK      # base 20 (identical)
    20:1.G.K    # base 20 (identical?)
    20:1_G_K    # base 20 (identical?)
    20:1.16.19  # base 20 (identical?)
    20:1_16_19  # base 20 (identical?)

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

   256:0.253.254.255   # base 256
   256:0_253_254_255   # base 256

-----

Of course, a key issue is that, in perl5, the treatment of numeric 
literals is not at all the same as the treatment of stringified 
numerics.  For example:

     0x00ff     # hex value ff
    '0x00ff'    # integer value 0, with trailing 'x00ff'

I think ways to solve this should be open to discussion.  Hopefully 
Luke can give us some proposals, since he's writing that part.

MikeL