mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* bignum.c (bary_small_rshift): Specify the higher BDIGIT instead of
sign bit. (big_shift3): Follow the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d0b5d2016d
commit
9f6c62ad5f
2 changed files with 9 additions and 5 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Fri Aug 16 09:17:00 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* bignum.c (bary_small_rshift): Specify the higher BDIGIT instead of
|
||||||
|
sign bit.
|
||||||
|
(big_shift3): Follow the above change.
|
||||||
|
|
||||||
Fri Aug 16 02:20:39 2013 Tanaka Akira <akr@fsij.org>
|
Fri Aug 16 02:20:39 2013 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* bignum.c (bary_mul_toom3): Reduce a branch.
|
* bignum.c (bary_mul_toom3): Reduce a branch.
|
||||||
|
|
8
bignum.c
8
bignum.c
|
@ -567,16 +567,14 @@ bary_small_lshift(BDIGIT *zds, const BDIGIT *xds, size_t n, int shift)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
bary_small_rshift(BDIGIT *zds, const BDIGIT *xds, size_t n, int shift, int sign_bit)
|
bary_small_rshift(BDIGIT *zds, const BDIGIT *xds, size_t n, int shift, BDIGIT higher_bdigit)
|
||||||
{
|
{
|
||||||
BDIGIT_DBL num = 0;
|
BDIGIT_DBL num = 0;
|
||||||
BDIGIT x;
|
BDIGIT x;
|
||||||
|
|
||||||
assert(0 <= shift && shift < BITSPERDIG);
|
assert(0 <= shift && shift < BITSPERDIG);
|
||||||
|
|
||||||
if (sign_bit) {
|
num = BIGUP(higher_bdigit);
|
||||||
num = (~(BDIGIT_DBL)0) << BITSPERDIG;
|
|
||||||
}
|
|
||||||
while (n--) {
|
while (n--) {
|
||||||
num = (num | xds[n]) >> shift;
|
num = (num | xds[n]) >> shift;
|
||||||
x = xds[n];
|
x = xds[n];
|
||||||
|
@ -4120,7 +4118,7 @@ big_shift3(VALUE x, int lshift_p, size_t shift_numdigits, int shift_numbits)
|
||||||
zn = xn - s1;
|
zn = xn - s1;
|
||||||
z = bignew(zn, 0);
|
z = bignew(zn, 0);
|
||||||
zds = BDIGITS(z);
|
zds = BDIGITS(z);
|
||||||
bary_small_rshift(zds, xds+s1, zn, s2, hibitsx != 0);
|
bary_small_rshift(zds, xds+s1, zn, s2, hibitsx != 0 ? BDIGMAX : 0);
|
||||||
twocomp2abs_bang(z, hibitsx != 0);
|
twocomp2abs_bang(z, hibitsx != 0);
|
||||||
}
|
}
|
||||||
RB_GC_GUARD(x);
|
RB_GC_GUARD(x);
|
||||||
|
|
Loading…
Reference in a new issue