develooper Front page | perl.perl6.language | Postings from October 2008

Re: Smooth numeric upgrades?

From:
Michael G Schwern
Date:
October 3, 2008 23:06
Subject:
Re: Smooth numeric upgrades?
Larry Wall wrote:
> 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

That's good [1] to hear, thanks.


> 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,

Oh don't worry, I do.  I just got so flustered when I saw Rakudo do the same
thing that Perl 5 does I was worried this got lost somewhere along the line.


[1] We need a polite way to say "less bad".


-- 
The mind is a terrible thing,
and it must be stopped.



Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About