mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
2 changed files with 14 additions and 9 deletions
|
@ -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>
|
||||
|
||||
* 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
|
||||
squaring.
|
||||
((bary_mul_toom3_branch): Ditto.
|
||||
(bary_mul_toom3_branch): Ditto.
|
||||
|
||||
Tue Jul 16 17:43:22 2013 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
|
|
16
bignum.c
16
bignum.c
|
@ -3263,14 +3263,12 @@ big_shift3(VALUE x, int lshift_p, size_t shift_numdigits, int shift_numbits)
|
|||
VALUE z;
|
||||
long xn;
|
||||
|
||||
if (LONG_MAX < shift_numdigits) {
|
||||
rb_raise(rb_eArgError, "too big number");
|
||||
}
|
||||
|
||||
s1 = shift_numdigits;
|
||||
s2 = shift_numbits;
|
||||
|
||||
if (lshift_p) {
|
||||
if (LONG_MAX < shift_numdigits) {
|
||||
rb_raise(rb_eArgError, "too big number");
|
||||
}
|
||||
s1 = shift_numdigits;
|
||||
s2 = shift_numbits;
|
||||
xn = RBIGNUM_LEN(x);
|
||||
z = bignew(xn+s1+1, RBIGNUM_SIGN(x));
|
||||
zds = BDIGITS(z);
|
||||
|
@ -3281,13 +3279,15 @@ big_shift3(VALUE x, int lshift_p, size_t shift_numdigits, int shift_numbits)
|
|||
else {
|
||||
long zn;
|
||||
BDIGIT hibitsx;
|
||||
if (s1 >= RBIGNUM_LEN(x)) {
|
||||
if (LONG_MAX < shift_numdigits || (size_t)RBIGNUM_LEN(x) <= shift_numdigits) {
|
||||
if (RBIGNUM_POSITIVE_P(x) ||
|
||||
bary_zero_p(BDIGITS(x), RBIGNUM_LEN(x)))
|
||||
return INT2FIX(0);
|
||||
else
|
||||
return INT2FIX(-1);
|
||||
}
|
||||
s1 = shift_numdigits;
|
||||
s2 = shift_numbits;
|
||||
hibitsx = abs2twocomp(&x, &xn);
|
||||
xds = BDIGITS(x);
|
||||
if (xn <= s1) {
|
||||
|
|
Loading…
Add table
Reference in a new issue