On Fri, 2 Feb 2001, Mike Wilson wrote:
> Just fooling around some, I ran this
> irb(main):001:0> 1020939**28329282
> obviously nothing good can come of this, but Ruby promptly grabbed some
> resources and began trying to compute this, finally ruby had 100% of the
> cpu and was still chugging.  Needless to say, I killed it soon after. 
> I then tried this:
> $ perl -e 'print 1020939**28329282, "\n"'
> Infinity

> So I'm curious why ruby seems to have no limit on the stupidity of the
> user ;).  Perl is known to hand the user a good (tree_branch_height -
> (user_height + 1)) worth of rope, but still recognizes that this is a
> fruitless pursuit. 

First of all, Perl makes no strict distinction between integers and
floats; it considers them all to be numbers. So when you perform '**'
it performs a floating-point exponentiation.

Second, Perl does not support large integers, so it drops significant
digits after 52 bits (15 decimal digits).

If you want you may require "bigint.pl" which is part of the standard
library. But that thing does not support operator overloading, and is not
a class either, and is much slower than Ruby's. And most of all it does
not support '**'. 

Ruby should be able to give an answer eventually. The resulting integer
should be approximately 70 megs in size. You may need a bit more RAM.



			*	*	*



Here's an expression that's valid syntax in both Perl and Ruby:

@a = 1 .. 10_000_000

However in practice Perl goes belly up.




matju