more test cases

This commit is contained in:
hyunghwan.chung 2019-04-08 09:10:02 +00:00
parent c671a16697
commit 9d1a8c5b61
2 changed files with 7 additions and 6 deletions

View File

@ -379,13 +379,18 @@ extend MyObject
[ self testBigintDiv: 100919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 129323482374892374238974238974238947328972389128387312892713891728391278 count: 2000 ], [ self testBigintDiv: 100919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 129323482374892374238974238974238947328972389128387312892713891728391278 count: 2000 ],
[ self testBigintDiv: 234897230919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 12932348237489237423897423897423894732897238912838731289271389172839127 count: 2000 ], [ self testBigintDiv: 234897230919283908998345873248972389472389791283789123712899089034258903482398198123912831 divisor: 12932348237489237423897423897423894732897238912838731289271389172839127 count: 2000 ],
[ self testBigintDiv: 16r1234567812345678123456781234567812345678123456781234567812345678123456781234567812345678 divisor: 16r12345678123456781234567812345678123456781234567812345678 count: 2000 ], [ self testBigintDiv: 16r1234567812345678123456781234567812345678123456781234567812345678123456781234567812345678 divisor: 16r12345678123456781234567812345678123456781234567812345678 count: 2000 ],
## 155-159
[ self testBigintDiv: 16r000089ab0000456700000123 divisor: 1 count: 2000 ], [ self testBigintDiv: 16r000089ab0000456700000123 divisor: 1 count: 2000 ],
[ self testBigintDiv: 16r000000030000000000008000 divisor: 16r000000010000000000002000 count: 2000 ], [ self testBigintDiv: 16r000000030000000000008000 divisor: 16r000000010000000000002000 count: 2000 ],
[ self testBigintDiv: 16rfffffffe0000000080000000 divisor: 16r0000ffff0000000080000000 count: 12345 ], [ self testBigintDiv: 16rfffffffe0000000080000000 divisor: 16r0000ffff0000000080000000 count: 12345 ],
[ self testBigintDiv: 16rfffffffffffffffe divisor: 16rffffffff count: 2000 ], [ self testBigintDiv: 16rfffffffffffffffe divisor: 16rffffffff count: 2000 ],
[ self testBigintDiv: 68651967526299315528548877601614136727014 divisor: 1729382256910270380 count: 1 ], [ self testBigintDiv: 68651967526299315528548877601614136727014 divisor: 1729382256910270380 count: 1 ],
## 160-164
[ self testBigintDiv: 43943618413704592900396132847030223073729048496 divisor: 1135814937804493543741046072006331 count: 1 ], [ self testBigintDiv: 43943618413704592900396132847030223073729048496 divisor: 1135814937804493543741046072006331 count: 1 ],
[ self testBigintDiv: 76733673740671314025981152630586699414203 divisor: 12682136550675277273 count: 1 ], [ self testBigintDiv: 76733673740671314025981152630586699414203 divisor: 12682136550675277273 count: 1 ],
[ self testBigintDiv: 265804060782114895959697138188904455994 divisor: 713053462628379038341886861235 count: 1],
## ========================= ## =========================

View File

@ -1727,22 +1727,18 @@ static MOO_INLINE moo_liw_t calculate_remainder (moo_t* moo, moo_liw_t* qr, moo_
for (b = 0, c = 0, c2 = 0, j = qr_start, k = 0; k < stop; j++, k++) for (b = 0, c = 0, c2 = 0, j = qr_start, k = 0; k < stop; j++, k++)
{ {
/* qr[j] = xmy(qr[j], 0, b); */
dw = (moo_lidw_t)qr[j] - b; dw = (moo_lidw_t)qr[j] - b;
b = (moo_liw_t)((dw >> MOO_LIW_BITS) & 1); /* b = -(dw mod BASE) */ b = (moo_liw_t)((dw >> MOO_LIW_BITS) & 1); /* b = -(dw mod BASE) */
qr[j] = (moo_liw_t)dw; qr[j] = (moo_liw_t)dw;
/* moo_liw_t qyk = axpy(q, divisor[k], 0, c); */
dw = ((moo_lidw_t)y[k] * quo) + c; dw = ((moo_lidw_t)y[k] * quo) + c;
c = (moo_liw_t)(dw >> MOO_LIW_BITS); c = (moo_liw_t)(dw >> MOO_LIW_BITS);
qyk = (moo_liw_t)dw; qyk = (moo_liw_t)dw;
/*c2 = 0; qr[j] = xmy(qr[j], qyk, c2); */
dw = (moo_lidw_t)qr[j] - qyk; dw = (moo_lidw_t)qr[j] - qyk;
c2 = (moo_liw_t)((dw >> MOO_LIW_BITS) & 1); c2 = (moo_liw_t)((dw >> MOO_LIW_BITS) & 1);
qr[j] = (moo_liw_t)dw; qr[j] = (moo_liw_t)dw;
/*b = xpy(b, c2, c);*/
dw = (moo_lidw_t)b + c2 + c; dw = (moo_lidw_t)b + c2 + c;
c = (moo_liw_t)(dw >> MOO_LIW_BITS); c = (moo_liw_t)(dw >> MOO_LIW_BITS);
b = (moo_liw_t)dw; b = (moo_liw_t)dw;
@ -1903,6 +1899,7 @@ static void divide_unsigned_array2 (moo_t* moo, const moo_liw_t* x, moo_oow_t xs
*/ */
for (i = 0; i < ys; i++) { r[i] = q[i]; q[i] = 0; } for (i = 0; i < ys; i++) { r[i] = q[i]; q[i] = 0; }
for (; i <= xs; i++) { q[i - ys] = q[i]; q[i] = 0; } for (; i <= xs; i++) { q[i - ys] = q[i]; q[i] = 0; }
} }
static void divide_unsigned_array3 (moo_t* moo, const moo_liw_t* x, moo_oow_t xs, const moo_liw_t* y, moo_oow_t ys, moo_liw_t* q, moo_liw_t* r) static void divide_unsigned_array3 (moo_t* moo, const moo_liw_t* x, moo_oow_t xs, const moo_liw_t* y, moo_oow_t ys, moo_liw_t* q, moo_liw_t* r)
@ -1992,8 +1989,8 @@ static void divide_unsigned_array3 (moo_t* moo, const moo_liw_t* x, moo_oow_t xs
{ {
dw = qhat * r[k]; dw = qhat * r[k];
di = qq[i] - ci - (dw & MOO_TYPE_MAX(moo_liw_t)); di = qq[i] - ci - (dw & MOO_TYPE_MAX(moo_liw_t));
qq[i] = di;
ci = (dw >> MOO_LIW_BITS) - (di >> MOO_LIW_BITS); ci = (dw >> MOO_LIW_BITS) - (di >> MOO_LIW_BITS);
qq[i] = (moo_liw_t)di;
} }
MOO_ASSERT (moo, i == j); MOO_ASSERT (moo, i == j);
di = qq[j] - ci; di = qq[j] - ci;
@ -2012,7 +2009,6 @@ static void divide_unsigned_array3 (moo_t* moo, const moo_liw_t* x, moo_oow_t xs
MOO_ASSERT (moo, i == j); MOO_ASSERT (moo, i == j);
/*MOO_ASSERT (moo, ci == 1);*/ /*MOO_ASSERT (moo, ci == 1);*/
qq[j] += ci; qq[j] += ci;
q[g] = qhat - 1; q[g] = qhat - 1;
} }
else else