minor code change. nothing meaningful

This commit is contained in:
hyunghwan.chung 2019-03-22 08:06:14 +00:00
parent 99e94bec93
commit 78970f370f

View File

@ -1460,6 +1460,7 @@ static void divide_unsigned_array (moo_t* moo, const moo_liw_t* x, moo_oow_t xs,
/* TODO: this function needs to be rewritten for performance improvement.
* the binary long division is extremely slow for a big number */
#if 0
/* Perform binary long division.
* http://en.wikipedia.org/wiki/Division_algorithm
* ---------------------------------------------------------------------
@ -1499,6 +1500,9 @@ static void divide_unsigned_array (moo_t* moo, const moo_liw_t* x, moo_oow_t xs,
}
}
}
#else
#endif
}
static moo_oop_t add_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t y)
@ -2080,35 +2084,40 @@ moo_oop_t moo_divints (moo_t* moo, moo_oop_t x, moo_oop_t y, int modulo, moo_oop
v = MOO_OOP_TO_SMOOI(y);
switch (v)
{
case 0:
case 0: /* divide by 0 */
moo_seterrnum (moo, MOO_EDIVBY0);
return MOO_NULL;
case 1:
case 1: /* divide by 1 */
z = clone_bigint(moo, x, MOO_OBJ_GET_SIZE(x));
if (!z) return MOO_NULL;
if (rem) *rem = MOO_SMOOI_TO_OOP(0);
return z;
case -1:
case -1: /* divide by -1 */
z = clone_bigint_negated(moo, x, MOO_OBJ_GET_SIZE(x));
if (!z) return MOO_NULL;
if (rem) *rem = MOO_SMOOI_TO_OOP(0);
return z;
/*
#if 0
default:
if (IS_POWER_OF_2(v))
{
/*
2**x = v
x = logv(2) = log(v) / log(2)
x is the number of shift to make */
TODO:
DO SHIFTING. how to get remainder..
if v is powerof2, do shifting???
z = clone_bigint_negated(moo, x, MOO_OBJ_GET_SIZE(x));
rshift_unsigned_array (z, MOO_OBJ_GET_SIZE(z), 10);
if (!z) return MOO_NULL;
rshift_unsigned_array (z, MOO_OBJ_GET_SIZE(z), log(v)/log(2));
}
*/
#ebduf
}
moo_pushvolat (moo, &x);