summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--bignum.c42
2 files changed, 27 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index a7e00cca44..eb15f745f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/bignum.c b/bignum.c
index bb6430c19d..d2f5ea3040 100644
--- a/bignum.c
+++ b/bignum.c
@@ -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;
}
/*