From 0fbe20532529e779d8c0d5280ce6b5322ac869d1 Mon Sep 17 00:00:00 2001 From: Kevin Ryde Date: Mon, 4 Dec 2006 23:38:24 +0000 Subject: [PATCH] (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". --- libguile/numbers.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libguile/numbers.c b/libguile/numbers.c index c1f11aecb..13e060ec1 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -3632,6 +3632,9 @@ scm_product (SCM x, SCM y) } } else if (SCM_REALP (x)) { 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)); } else if (SCM_BIGP (y)) { 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)) { 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), SCM_INUM (y) * SCM_COMPLEX_IMAG (x)); } else if (SCM_BIGP (y)) {