* 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:
parent
f0a75dbba8
commit
44a1d99635
@ -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>
|
Thu Jun 18 22:31:38 2009 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* rational.c (nurat_s_convert): calls to_r when the given argument
|
* 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>
|
Wed Jun 17 06:48:28 2009 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* st.c, include/ruby/st.h (st_memsize): added. This function returns
|
* 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>
|
Wed Jun 17 06:19:06 2009 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
42
bignum.c
42
bignum.c
@ -2412,23 +2412,23 @@ big_fdiv(VALUE x, VALUE y)
|
|||||||
case T_FIXNUM:
|
case T_FIXNUM:
|
||||||
y = rb_int2big(FIX2LONG(y));
|
y = rb_int2big(FIX2LONG(y));
|
||||||
case T_BIGNUM: {
|
case T_BIGNUM: {
|
||||||
bigtrunc(y);
|
bigtrunc(y);
|
||||||
l = RBIGNUM_LEN(y) - 1;
|
l = RBIGNUM_LEN(y) - 1;
|
||||||
ey = l * BITSPERDIG;
|
ey = l * BITSPERDIG;
|
||||||
ey += bdigbitsize(BDIGITS(y)[l]);
|
ey += bdigbitsize(BDIGITS(y)[l]);
|
||||||
ey -= DBL_BIGDIG * BITSPERDIG;
|
ey -= DBL_BIGDIG * BITSPERDIG;
|
||||||
if (ey) y = big_shift(y, ey);
|
if (ey) y = big_shift(y, ey);
|
||||||
bignum:
|
bignum:
|
||||||
bigdivrem(x, y, &z, 0);
|
bigdivrem(x, y, &z, 0);
|
||||||
l = ex - ey;
|
l = ex - ey;
|
||||||
#if SIZEOF_LONG > SIZEOF_INT
|
#if SIZEOF_LONG > SIZEOF_INT
|
||||||
{
|
{
|
||||||
/* Visual C++ can't be here */
|
/* Visual C++ can't be here */
|
||||||
if (l > INT_MAX) return DBL2NUM(ruby_div0(1.0));
|
if (l > INT_MAX) return DBL2NUM(ruby_div0(1.0));
|
||||||
if (l < INT_MIN) return DBL2NUM(0.0);
|
if (l < INT_MIN) return DBL2NUM(0.0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return DBL2NUM(ldexp(big2dbl(z), (int)l));
|
return DBL2NUM(ldexp(big2dbl(z), (int)l));
|
||||||
}
|
}
|
||||||
case T_FLOAT:
|
case T_FLOAT:
|
||||||
y = dbl2big(ldexp(frexp(RFLOAT_VALUE(y), &i), DBL_MANT_DIG));
|
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);
|
y = rb_to_int(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neg) return big_rshift(x, shift);
|
x = neg ? big_rshift(x, shift) : big_lshift(x, shift);
|
||||||
return big_lshift(x, shift);
|
return bignorm(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -2923,7 +2923,7 @@ big_lshift(VALUE x, unsigned long shift)
|
|||||||
num = BIGDN(num);
|
num = BIGDN(num);
|
||||||
}
|
}
|
||||||
*zds = BIGLO(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);
|
y = rb_to_int(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (neg) return big_lshift(x, shift);
|
x = neg ? big_lshift(x, shift) : big_rshift(x, shift);
|
||||||
return big_rshift(x, shift);
|
return bignorm(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
@ -3006,7 +3006,7 @@ big_rshift(VALUE x, unsigned long shift)
|
|||||||
if (!RBIGNUM_SIGN(x)) {
|
if (!RBIGNUM_SIGN(x)) {
|
||||||
get2comp(z);
|
get2comp(z);
|
||||||
}
|
}
|
||||||
return bignorm(z);
|
return z;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user