1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 22:10:21 +02:00

(scm_make_ratio): For inum/bignum integer detection, use

x==SCM_MOST_NEGATIVE_FIXNUM explicitly, for clarity and to avoid
calling mpz_cmp_ui in most cases.
This commit is contained in:
Kevin Ryde 2004-04-05 23:31:20 +00:00
parent f1c6bec637
commit 3271a325c8

View file

@ -369,9 +369,12 @@ scm_make_ratio (SCM numerator, SCM denominator)
else
{
/* When x == SCM_MOST_NEGATIVE_FIXNUM we could have the negative
of that value for the denominator, as a bignum. */
long abs_x = (x >= 0 ? x : -x);
if (mpz_cmpabs_ui (SCM_I_BIG_MPZ (denominator), abs_x) == 0)
of that value for the denominator, as a bignum. Apart from
that case, abs(bignum) > abs(inum) so inum/bignum is not an
integer. */
if (x == SCM_MOST_NEGATIVE_FIXNUM
&& mpz_cmp_ui (SCM_I_BIG_MPZ (denominator),
- SCM_MOST_NEGATIVE_FIXNUM) == 0)
return SCM_MAKINUM(-1);
}
}