From 3d4e0396ca9ffd5bac11f70c6d022cb9168b34f8 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Wed, 3 Apr 2019 19:28:14 +0000 Subject: [PATCH] debugging bigint division --- moo/kernel/test-001.moo | 2 +- moo/lib/bigint.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/moo/kernel/test-001.moo b/moo/kernel/test-001.moo index d954422..8e2485d 100644 --- a/moo/kernel/test-001.moo +++ b/moo/kernel/test-001.moo @@ -132,7 +132,7 @@ extend MyObject q := divd div: divr. r := divd rem: divr. - ifnot (divd = (q * divr + r)) { divd dump. divr dump. q dump. r dump. ^false. }. + ifnot (divd = (q * divr + r)) { i dump. divd dump. divr dump. q dump. r dump. ^false. }. i := i + 1. }. diff --git a/moo/lib/bigint.c b/moo/lib/bigint.c index 7baecfe..4f090b9 100644 --- a/moo/lib/bigint.c +++ b/moo/lib/bigint.c @@ -1630,7 +1630,7 @@ static moo_liw_t adjust_for_over_estimate (moo_liw_t y1, moo_liw_t y2, moo_liw_t c = (moo_liw_t)(dw >> MOO_LIW_BITS); y2q = (moo_liw_t)dw; - if (c > xi || (c = xi && y2q > xi2)) + if (c > xi || (c == xi && y2q > xi2)) { q--; // too large by 1 @@ -1643,7 +1643,7 @@ static moo_liw_t adjust_for_over_estimate (moo_liw_t y1, moo_liw_t y2, moo_liw_t dw = ((moo_lidw_t)q * y2); y2q = (moo_liw_t)dw; c = (moo_liw_t)(dw >> MOO_LIW_BITS); - if (c > xi || (c = xi && y2q > xi2)) q--; // too large by 2 + if (c > xi || (c == xi && y2q > xi2)) q--; // too large by 2 } } @@ -1972,7 +1972,7 @@ static moo_oop_t divide_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t y, MOO_ASSERT (moo, !is_less_unsigned(x, y)); moo_pushvolat (moo, &x); moo_pushvolat (moo, &y); -//#define USE_DIVIDE_UNSIGNED_ARRAY2 +/*#define USE_DIVIDE_UNSIGNED_ARRAY2*/ #if defined(USE_DIVIDE_UNSIGNED_ARRAY2) qq = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, MOO_OBJ_GET_SIZE(x) + 1); #else