1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

Fix scm_to_mpz

Another change of long to intptr_t in numbers.c

* libguile/numbers.c (scm_to_mpz): long to intptr_t fix
This commit is contained in:
Michael Gran 2025-03-30 19:05:51 -07:00
parent dee2ac91df
commit e371906dac

View file

@ -6881,14 +6881,14 @@ scm_to_mpz (SCM val, mpz_t rop)
#if SCM_LONG_BIT >= SCM_I_FIXNUM_BIT
// Cast to long and directly pass to GMP.
mpz_set_si (rop, (long)inum);
#elif (2 * SCM_LONG_BIT) > SCM_I_FIXNUM_BIT
#elif (2 * SCM_INTPTR_T_BIT) > SCM_I_FIXNUM_BIT
scm_t_inum inum_abs = inum;
if (inum < 0)
inum_abs *= -1;
long high = inum_abs >> (SCM_LONG_BIT - 1);
long low = (long)(inum_abs & ((((scm_t_inum)1) << (SCM_LONG_BIT - 1)) - 1));
intptr_t high = inum_abs >> (SCM_INTPTR_T_BIT - 1);
intptr_t low = (intptr_t)(inum_abs & ((((scm_t_inum)1) << (SCM_INTPTR_T_BIT - 1)) - 1));
mpz_set_si (rop, high);
mpz_mul_2exp (rop, rop, SCM_LONG_BIT - 1);
mpz_mul_2exp (rop, rop, SCM_INTPTR_T_BIT - 1);
mpz_add_ui (rop, rop, low);
if (inum < 0)
mpz_neg (rop, rop);