* bignum.c (bigdivrem): Use a BDIGIT variable to store the return

value of bigdivrem_single.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-06-15 23:56:32 +00:00
Родитель 00a95f15bc
Коммит d631642a2e
2 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,8 @@
Sun Jun 16 08:55:22 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (bigdivrem): Use a BDIGIT variable to store the return
value of bigdivrem_single.
Sun Jun 16 08:43:59 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (bary_divmod): New function.

Просмотреть файл

@ -3951,12 +3951,12 @@ bary_divmod(BDIGIT *qds, long nq, BDIGIT *rds, long nr, BDIGIT *xds, long nx, BD
MEMZERO(zds+nx, BDIGIT, nz-nx);
if ((yds[ny-1] >> (BITSPERDIG-1)) & 1) {
/* digits_bigdivrem_multi_sub will not modify y.
/* bigdivrem_normal will not modify y.
* So use yds directly. */
tds = yds;
}
else {
/* digits_bigdivrem_multi_sub will modify y.
/* bigdivrem_normal will modify y.
* So use rds as a temporary buffer. */
MEMCPY(rds, yds, BDIGIT, ny);
tds = rds;
@ -3986,7 +3986,6 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
VALUE z, zz;
VALUE tmpy = 0, tmpz = 0;
BDIGIT *xds, *yds, *zds, *tds;
BDIGIT_DBL t2;
BDIGIT dd;
yds = BDIGITS(y);
@ -4006,9 +4005,9 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp)
dd = yds[0];
z = bignew(nx, RBIGNUM_SIGN(x)==RBIGNUM_SIGN(y));
zds = BDIGITS(z);
t2 = bigdivrem_single(zds, xds, nx, dd);
dd = bigdivrem_single(zds, xds, nx, dd);
if (modp) {
*modp = rb_uint2big((VALUE)t2);
*modp = rb_uint2big((VALUE)dd);
RBIGNUM_SET_SIGN(*modp, RBIGNUM_SIGN(x));
}
if (divp) *divp = z;