On Fri, Oct 03, 2008 at 11:57:30PM -0400, Michael G Schwern wrote:
: What's the status of numeric upgrades in Perl 6?  Is see the docs say "Perl 6
: intrinsically supports big integers and rationals through its system of type
: declarations. Int automatically supports promotion to arbitrary precision" but
: it looks like it's doing the same thing as Perl 5.
: 
: $ ./perl6 -e 'say 2**40'
: 1099511627776
: 
: $ ./perl6 -e 'say 2**50'
: 1.12589990684262e+15
: 
: $ ./perl6 -e 'say 2**1100'
: inf

The status of numeric upgrades in Perl 6 is fine.  It's rakudo that
doesn't do so well.  :)

As another datapoint:

$  pugs -e 'say 2**40'
1099511627776
$ pugs -e 'say 2**50'
1125899906842624
$ pugs -e 'say 2**1100'
13582985290493858492773514283592667786034938469317445497485196697278130927542418487205392083207560592298578262953847383475038725543234929971155548342800628721885763499406390331782864144164680730766837160526223176512798435772129956553355286032203080380775759732320198985094884004069116123084147875437183658467465148948790552744165376

I don't think of Int as a type that automatically upgrades.  I think
of it as an arbritrarily large integer that the implementation can in
some cases choose to optimize to a smaller or faster representation,
but only if that can be transparent to the user (apart from the size
and speed effects).  Certainly this should be the case for anything
declared "Int".  A native "int" is another matter, but that's just
a storage constraint, and probably shouldn't influence intermediate
computations, which are done in Int.  So it shouldn't matter whether 2
and 1100 are stored in Int or int form; the result should be the same
(subject, perhaps to pragmatic control of temp types).

Larry

Reply via email to