1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-08 22:50:27 +02:00

(scm_product): For flonum*inum and complex*inum, return

exact 0 if inum==0.  Already done for inum*flonum and inum*complex,
and as per R5RS section "Exactness".
This commit is contained in:
Kevin Ryde 2006-12-04 23:38:24 +00:00
parent e91ba10a98
commit 0fbe205325

View file

@ -3632,6 +3632,9 @@ scm_product (SCM x, SCM y)
} }
} else if (SCM_REALP (x)) { } else if (SCM_REALP (x)) {
if (SCM_INUMP (y)) { if (SCM_INUMP (y)) {
/* inexact*exact0 => exact 0, per R5RS "Exactness" section */
if (SCM_EQ_P (y, SCM_INUM0))
return y;
return scm_make_real (SCM_INUM (y) * SCM_REAL_VALUE (x)); return scm_make_real (SCM_INUM (y) * SCM_REAL_VALUE (x));
} else if (SCM_BIGP (y)) { } else if (SCM_BIGP (y)) {
return scm_make_real (scm_i_big2dbl (y) * SCM_REAL_VALUE (x)); return scm_make_real (scm_i_big2dbl (y) * SCM_REAL_VALUE (x));
@ -3645,6 +3648,9 @@ scm_product (SCM x, SCM y)
} }
} else if (SCM_COMPLEXP (x)) { } else if (SCM_COMPLEXP (x)) {
if (SCM_INUMP (y)) { if (SCM_INUMP (y)) {
/* inexact*exact0 => exact 0, per R5RS "Exactness" section */
if (SCM_EQ_P (y, SCM_INUM0))
return y;
return scm_make_complex (SCM_INUM (y) * SCM_COMPLEX_REAL (x), return scm_make_complex (SCM_INUM (y) * SCM_COMPLEX_REAL (x),
SCM_INUM (y) * SCM_COMPLEX_IMAG (x)); SCM_INUM (y) * SCM_COMPLEX_IMAG (x));
} else if (SCM_BIGP (y)) { } else if (SCM_BIGP (y)) {