ruby-changes:30496
From: akr <ko1@a...>
Date: Fri, 16 Aug 2013 09:19:56 +0900 (JST)
Subject: [ruby-changes:30496] akr:r42575 (trunk): * bignum.c (bary_small_rshift): Specify the higher BDIGIT instead of
akr 2013-08-16 09:19:51 +0900 (Fri, 16 Aug 2013) New Revision: 42575 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42575 Log: * bignum.c (bary_small_rshift): Specify the higher BDIGIT instead of sign bit. (big_shift3): Follow the above change. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 42574) +++ ChangeLog (revision 42575) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Aug 16 09:17:00 2013 Tanaka Akira <akr@f...> + + * 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@f...> * bignum.c (bary_mul_toom3): Reduce a branch. Index: bignum.c =================================================================== --- bignum.c (revision 42574) +++ bignum.c (revision 42575) @@ -567,16 +567,14 @@ bary_small_lshift(BDIGIT *zds, const BDI https://github.com/ruby/ruby/blob/trunk/bignum.c#L567 } 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 x; assert(0 <= shift && shift < BITSPERDIG); - if (sign_bit) { - num = (~(BDIGIT_DBL)0) << BITSPERDIG; - } + num = BIGUP(higher_bdigit); while (n--) { num = (num | xds[n]) >> shift; x = xds[n]; @@ -4120,7 +4118,7 @@ big_shift3(VALUE x, int lshift_p, size_t https://github.com/ruby/ruby/blob/trunk/bignum.c#L4118 zn = xn - s1; z = bignew(zn, 0); 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); } RB_GC_GUARD(x); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/