* bignum.c (big_shift3): Big shift width is not a problem for right
shift. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3569c6c3a6
commit
4106413465
@ -1,3 +1,8 @@
|
|||||||
|
Tue Jul 16 19:05:12 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (big_shift3): Big shift width is not a problem for right
|
||||||
|
shift.
|
||||||
|
|
||||||
Tue Jul 16 18:50:08 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue Jul 16 18:50:08 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_count): [DOC] fix typo. Array#count uses ==, not
|
* array.c (rb_ary_count): [DOC] fix typo. Array#count uses ==, not
|
||||||
@ -7,7 +12,7 @@ Tue Jul 16 18:35:48 2013 Tanaka Akira <akr@fsij.org>
|
|||||||
|
|
||||||
* bignum.c (bary_mul_karatsuba): Avoid duplicate calculation when
|
* bignum.c (bary_mul_karatsuba): Avoid duplicate calculation when
|
||||||
squaring.
|
squaring.
|
||||||
((bary_mul_toom3_branch): Ditto.
|
(bary_mul_toom3_branch): Ditto.
|
||||||
|
|
||||||
Tue Jul 16 17:43:22 2013 Koichi Sasada <ko1@atdot.net>
|
Tue Jul 16 17:43:22 2013 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
8
bignum.c
8
bignum.c
@ -3263,14 +3263,12 @@ big_shift3(VALUE x, int lshift_p, size_t shift_numdigits, int shift_numbits)
|
|||||||
VALUE z;
|
VALUE z;
|
||||||
long xn;
|
long xn;
|
||||||
|
|
||||||
|
if (lshift_p) {
|
||||||
if (LONG_MAX < shift_numdigits) {
|
if (LONG_MAX < shift_numdigits) {
|
||||||
rb_raise(rb_eArgError, "too big number");
|
rb_raise(rb_eArgError, "too big number");
|
||||||
}
|
}
|
||||||
|
|
||||||
s1 = shift_numdigits;
|
s1 = shift_numdigits;
|
||||||
s2 = shift_numbits;
|
s2 = shift_numbits;
|
||||||
|
|
||||||
if (lshift_p) {
|
|
||||||
xn = RBIGNUM_LEN(x);
|
xn = RBIGNUM_LEN(x);
|
||||||
z = bignew(xn+s1+1, RBIGNUM_SIGN(x));
|
z = bignew(xn+s1+1, RBIGNUM_SIGN(x));
|
||||||
zds = BDIGITS(z);
|
zds = BDIGITS(z);
|
||||||
@ -3281,13 +3279,15 @@ big_shift3(VALUE x, int lshift_p, size_t shift_numdigits, int shift_numbits)
|
|||||||
else {
|
else {
|
||||||
long zn;
|
long zn;
|
||||||
BDIGIT hibitsx;
|
BDIGIT hibitsx;
|
||||||
if (s1 >= RBIGNUM_LEN(x)) {
|
if (LONG_MAX < shift_numdigits || (size_t)RBIGNUM_LEN(x) <= shift_numdigits) {
|
||||||
if (RBIGNUM_POSITIVE_P(x) ||
|
if (RBIGNUM_POSITIVE_P(x) ||
|
||||||
bary_zero_p(BDIGITS(x), RBIGNUM_LEN(x)))
|
bary_zero_p(BDIGITS(x), RBIGNUM_LEN(x)))
|
||||||
return INT2FIX(0);
|
return INT2FIX(0);
|
||||||
else
|
else
|
||||||
return INT2FIX(-1);
|
return INT2FIX(-1);
|
||||||
}
|
}
|
||||||
|
s1 = shift_numdigits;
|
||||||
|
s2 = shift_numbits;
|
||||||
hibitsx = abs2twocomp(&x, &xn);
|
hibitsx = abs2twocomp(&x, &xn);
|
||||||
xds = BDIGITS(x);
|
xds = BDIGITS(x);
|
||||||
if (xn <= s1) {
|
if (xn <= s1) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user