diff --git a/src/c/big.d b/src/c/big.d index 86bb43b81..246d72762 100644 --- a/src/c/big.d +++ b/src/c/big.d @@ -187,7 +187,7 @@ _ecl_big_plus_fix(cl_object a, cl_fixnum b) cl_index size_z = size_a + limbs_per_fixnum; cl_object z = _ecl_alloc_compact_bignum(size_z); if (b < 0) { - _ecl_big_sub_ui(z, a, b); + _ecl_big_sub_ui(z, a, (-b)); } else { _ecl_big_add_ui(z, a, b); } diff --git a/src/c/num_arith.d b/src/c/num_arith.d index 519e61a0f..c3ca69407 100644 --- a/src/c/num_arith.d +++ b/src/c/num_arith.d @@ -273,14 +273,7 @@ ecl_plus(cl_object x, cl_object y) case t_fixnum: return ecl_make_integer(fix(x) + fix(y)); case t_bignum: - if ((i = fix(x)) == 0) - return(y); - z = _ecl_big_register0(); - if (i > 0) - _ecl_big_add_ui(z, y, i); - else - _ecl_big_sub_ui(z, y, -i); - return _ecl_big_register_normalize(z); + return _ecl_big_plus_fix(y, fix(x)); case t_ratio: z = ecl_times(x, y->ratio.den); z = ecl_plus(z, y->ratio.num); @@ -307,18 +300,9 @@ ecl_plus(cl_object x, cl_object y) case t_bignum: switch (type_of(y)) { case t_fixnum: - if ((j = fix(y)) == 0) - return(x); - z = _ecl_big_register0(); - if (j > 0) - _ecl_big_add_ui(z, x, j); - else - _ecl_big_sub_ui(z, x, (-j)); - return _ecl_big_register_normalize(z); + return _ecl_big_plus_fix(x, fix(y)); case t_bignum: - z = _ecl_big_register0(); - _ecl_big_add(z, x, y); - return _ecl_big_register_normalize(z); + return _ecl_big_plus_big(x, y); case t_ratio: z = ecl_times(x, y->ratio.den); z = ecl_plus(z, y->ratio.num);