Jean-Claude Arbaut wrote:
> Hi,
> 
> is there a limit on a Bignum size ?
> I get this:
> 
> irb> a=2**262144; a % 10**20
> => 62605349934298300416
> 
> irb> a=2**262145; a
> (irb):1: warning: in a**b, b may be too big
> => Infinity

It's with ruby 1.8.5. Don't try to print the
result with ruby 1.8.2, because the computation works,
and the result is large ! :-)

For example, in 1.8.2:

irb(main):001:0> a=2**100000000; a%10**20
=> 4130048177787109376

(computations with 3**n are much more slower,
but it was expected, since ruby uses base 2)

> But then,
> 
> irb(main):004:0> b=a+a; b % 10**20
> => 25210699868596600832
> 
> and even:
> 
> irb> c=a**31; c % 10**20
> => 54593967939561455616
> 
> The problem continues here:
> 
> irb> d=a**32; d % 10**20
> (irb):21: warning: in a**b, b may be too big
> (irb):21: warning: Bignum out of Float range
> => NaN
> 
> But I can compute this value anyway:
> 
> irb> e=c*a; e % 10**20
> => 85551374411818336256
> 
> Is there a bug in the ** method ?