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

(scm_modular_expt): Return a negative remainder for a

negative divisor, the same as `modulo' does.
This commit is contained in:
Kevin Ryde 2004-03-25 21:51:39 +00:00
parent d6628681cd
commit b7b8c57576

View file

@ -1626,6 +1626,10 @@ SCM_DEFINE (scm_modular_expt, "modulo-expt", 3, 0, 0,
n_tmp,
k_tmp,
m_tmp);
if (mpz_sgn (m_tmp) < 0 && mpz_sgn (SCM_I_BIG_MPZ (result)) != 0)
mpz_add (SCM_I_BIG_MPZ (result), SCM_I_BIG_MPZ (result), m_tmp);
cleanup:
mpz_clear (m_tmp);
mpz_clear (k_tmp);