зеркало из https://github.com/github/ruby.git
* bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
26feae3958
Коммит
adaa5650cd
|
@ -1,3 +1,7 @@
|
|||
Tue Aug 13 23:01:16 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (bigdivrem_restoring): Extracted from bigdivrem_normal.
|
||||
|
||||
Tue Aug 13 22:12:59 2013 Kenichi Kamiya <kachick1@gmail.com>
|
||||
|
||||
* random.c (rb_random_ulong_limited): coerce before check negative.
|
||||
|
|
37
bignum.c
37
bignum.c
|
@ -2697,23 +2697,11 @@ bigdivrem_single(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT y)
|
|||
}
|
||||
|
||||
static void
|
||||
bigdivrem_normal(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, BDIGIT *yds, size_t yn, int needs_mod)
|
||||
bigdivrem_restoring(BDIGIT *zds, size_t zn, size_t xn, BDIGIT *yds, size_t yn)
|
||||
{
|
||||
struct big_div_struct bds;
|
||||
BDIGIT q;
|
||||
int shift;
|
||||
|
||||
q = yds[yn-1];
|
||||
shift = nlz(q);
|
||||
if (shift) {
|
||||
bary_small_lshift(yds, yds, yn, shift);
|
||||
zds[xn] = bary_small_lshift(zds, xds, xn, shift);
|
||||
}
|
||||
else {
|
||||
MEMCPY(zds, xds, BDIGIT, xn);
|
||||
zds[xn] = 0;
|
||||
}
|
||||
if (xn+1 < zn) zds[xn+1] = 0;
|
||||
assert(BDIGIT_MSB(yds[yn-1]));
|
||||
|
||||
bds.xn = xn;
|
||||
bds.yn = yn;
|
||||
|
@ -2735,6 +2723,27 @@ bigdivrem_normal(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, BDIGIT *y
|
|||
else {
|
||||
bigdivrem1(&bds);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
bigdivrem_normal(BDIGIT *zds, size_t zn, const BDIGIT *xds, size_t xn, BDIGIT *yds, size_t yn, int needs_mod)
|
||||
{
|
||||
BDIGIT q;
|
||||
int shift;
|
||||
|
||||
q = yds[yn-1];
|
||||
shift = nlz(q);
|
||||
if (shift) {
|
||||
bary_small_lshift(yds, yds, yn, shift);
|
||||
zds[xn] = bary_small_lshift(zds, xds, xn, shift);
|
||||
}
|
||||
else {
|
||||
MEMCPY(zds, xds, BDIGIT, xn);
|
||||
zds[xn] = 0;
|
||||
}
|
||||
if (xn+1 < zn) zds[xn+1] = 0;
|
||||
|
||||
bigdivrem_restoring(zds, zn, xn, yds, yn);
|
||||
|
||||
if (needs_mod && shift) {
|
||||
bary_small_rshift(zds, zds, yn, shift, 0);
|
||||
|
|
Загрузка…
Ссылка в новой задаче