1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* bignum.c (big_lshift, big_rshift): return Bignum always without

normalization.  [ruby-dev:38679]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-06-18 23:14:08 +00:00
parent f0a75dbba8
commit 44a1d99635
2 changed files with 27 additions and 22 deletions

View file

@ -1,3 +1,8 @@
Fri Jun 19 08:14:07 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* bignum.c (big_lshift, big_rshift): return Bignum always withou
normalization. [ruby-dev:38679]
Thu Jun 18 22:31:38 2009 Tadayoshi Funaba <tadf@dotrb.org>
* rational.c (nurat_s_convert): calls to_r when the given argument
@ -124,7 +129,7 @@ Wed Jun 17 07:04:33 2009 Koichi Sasada <ko1@atdot.net>
Wed Jun 17 06:48:28 2009 Koichi Sasada <ko1@atdot.net>
* st.c, include/ruby/st.h (st_memsize): added. This function returns
the memory usage of st_talbe.
the memory usage of st_table.
Wed Jun 17 06:19:06 2009 Koichi Sasada <ko1@atdot.net>

View file

@ -2412,23 +2412,23 @@ big_fdiv(VALUE x, VALUE y)
case T_FIXNUM:
y = rb_int2big(FIX2LONG(y));
case T_BIGNUM: {
bigtrunc(y);
l = RBIGNUM_LEN(y) - 1;
ey = l * BITSPERDIG;
ey += bdigbitsize(BDIGITS(y)[l]);
ey -= DBL_BIGDIG * BITSPERDIG;
if (ey) y = big_shift(y, ey);
bignum:
bigdivrem(x, y, &z, 0);
l = ex - ey;
bigtrunc(y);
l = RBIGNUM_LEN(y) - 1;
ey = l * BITSPERDIG;
ey += bdigbitsize(BDIGITS(y)[l]);
ey -= DBL_BIGDIG * BITSPERDIG;
if (ey) y = big_shift(y, ey);
bignum:
bigdivrem(x, y, &z, 0);
l = ex - ey;
#if SIZEOF_LONG > SIZEOF_INT
{
/* Visual C++ can't be here */
if (l > INT_MAX) return DBL2NUM(ruby_div0(1.0));
if (l < INT_MIN) return DBL2NUM(0.0);
}
{
/* Visual C++ can't be here */
if (l > INT_MAX) return DBL2NUM(ruby_div0(1.0));
if (l < INT_MIN) return DBL2NUM(0.0);
}
#endif
return DBL2NUM(ldexp(big2dbl(z), (int)l));
return DBL2NUM(ldexp(big2dbl(z), (int)l));
}
case T_FLOAT:
y = dbl2big(ldexp(frexp(RFLOAT_VALUE(y), &i), DBL_MANT_DIG));
@ -2896,8 +2896,8 @@ rb_big_lshift(VALUE x, VALUE y)
y = rb_to_int(y);
}
if (neg) return big_rshift(x, shift);
return big_lshift(x, shift);
x = neg ? big_rshift(x, shift) : big_lshift(x, shift);
return bignorm(x);
}
static VALUE
@ -2923,7 +2923,7 @@ big_lshift(VALUE x, unsigned long shift)
num = BIGDN(num);
}
*zds = BIGLO(num);
return bignorm(z);
return z;
}
/*
@ -2962,8 +2962,8 @@ rb_big_rshift(VALUE x, VALUE y)
y = rb_to_int(y);
}
if (neg) return big_lshift(x, shift);
return big_rshift(x, shift);
x = neg ? big_lshift(x, shift) : big_rshift(x, shift);
return bignorm(x);
}
static VALUE
@ -3006,7 +3006,7 @@ big_rshift(VALUE x, unsigned long shift)
if (!RBIGNUM_SIGN(x)) {
get2comp(z);
}
return bignorm(z);
return z;
}
/*