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

Re: Smooth numeric upgrades?

From:
Bob Rogers
Date:
October 4, 2008 14:10
Subject:
Re: Smooth numeric upgrades?
   From: "Patrick R. Michaud" <pmichaud@pobox.com>
   Date: Sat, 4 Oct 2008 09:41:22 -0500

   On Fri, Oct 03, 2008 at 09:47:38PM -0700, 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.
   > 
   > The status of numeric upgrades in Perl 6 is fine.  It's rakudo that
   > doesn't do so well.  :)

   Correct.  I suspect that eventually the Rakudo developers will have
   to develop a custom set of PMCs for Perl 6 behaviors rather than
   relying on the Parrot ones.

The Parrot behavior in this case may be closer than you think.  After
applying the patch below, I get the expected output from Rakudo:

	rogers@rgr> ./perl6 -e 'say 2**40'
	1099511627776
	rogers@rgr> ./perl6 -e 'say 2**50'
	1125899906842624
	rogers@rgr> ./perl6 -e 'say 2**1100'
	13582985290493858492773514283592667786034938469317445497485196697278130927542418487205392083207560592298578262953847383475038725543234929971155548342800628721885763499406390331782864144164680730766837160526223176512798435772129956553355286032203080380775759732320198985094884004069116123084147875437183658467465148948790552744165376
	rogers@rgr> 

It does produces >300 spectest_regression failures, though, so I don't
claim the patch is right.

   Parrot doesn't currently downgrade BigInt PMCs to Integer when it
should, though.

					-- Bob Rogers
					   http://rgrjr.dyndns.org/





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