F. Senault wrote:

> I've made the test with ruby 1.8.4 : it works fine.  Then, I upgraded to
> ruby 1.8.5 and it fails as described by the OP.
> 
> FWIW :
> 
> 14:13 fred@talisker:~> ruby -v
> ruby 1.8.5 (2006-08-25) [i386-freebsd5]
> 
> Fred

Thanks for the answers.
Actually, it's not a bug, it's a feature :-)

Here's a piece of bignum.c, with "@" on the important lines:

-----------------------------
VALUE
rb_big_pow(x, y)
     VALUE x, y;
{
     double d;
     long yy;

     if (y == INT2FIX(0)) return INT2FIX(1);
     switch (TYPE(y)) {
       case T_FLOAT:
         d = RFLOAT(y)->value;
         break;

@      case T_BIGNUM:
@        rb_warn("in a**b, b may be too big");
@        d = rb_big2dbl(y);
         break;

       case T_FIXNUM:
         yy = FIX2LONG(y);
         if (yy > 0) {
             VALUE z = x;

  @           if (RBIGNUM(x)->len * SIZEOF_BDIGITS * yy > 1024*1024) {
  @               rb_warn("in a**b, b may be too big");
  @               d = (double)yy;
                 break;
             }
-----------------------------


Hence, 2^y when y is a bignum (that is, y > 2^30 - 1), always
raises a warning. And if y is a Fixnum, that depends on
the size of the result (a warning when there is about 1 million
binary digits). It's rather annoying to get a float in that case...
but I guess it's supposed to prevent a very long computation (that
cannot be interrupted by Ctrl-C) when there is a mistake in the
program.