While nosing around nearby stuff I noticed (* 0 1.0) => 0 (* 0 1+1i) => 0 but (* 1.0 0) => 0.0 (* 1+1i 0) => 0.0
which seems a bit inconsistent. R5RS "Exactness" reads like either exact or inexact is permitted, but I imagine it ought to be the same whichever way around you write the args. I think I'll change the latter two to exact 0.
--- numbers.c.~1.135.2.22.~ 2006-03-20 08:48:19.000000000 +1100 +++ numbers.c 2006-12-03 15:59:32.000000000 +1100 @@ -3632,6 +3632,9 @@ } } else if (SCM_REALP (x)) { if (SCM_INUMP (y)) { + /* inexact*exact0 is 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 @@ } } else if (SCM_COMPLEXP (x)) { if (SCM_INUMP (y)) { + /* inexact*exact0 is 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)) {
--- numbers.c.~1.281.2.7.~ 2006-09-27 11:34:11.000000000 +1000 +++ numbers.c 2006-12-03 16:08:52.000000000 +1100 @@ -4492,7 +4492,12 @@ else if (SCM_REALP (x)) { if (SCM_I_INUMP (y)) - return scm_from_double (SCM_I_INUM (y) * SCM_REAL_VALUE (x)); + { + /* inexact*exact0 is exact 0, per R5RS "Exactness" section */ + if (scm_is_eq (y, SCM_INUM0)) + return y; + return scm_from_double (SCM_I_INUM (y) * SCM_REAL_VALUE (x)); + } else if (SCM_BIGP (y)) { double result = mpz_get_d (SCM_I_BIG_MPZ (y)) * SCM_REAL_VALUE (x); @@ -4512,8 +4517,13 @@ else if (SCM_COMPLEXP (x)) { if (SCM_I_INUMP (y)) - return scm_c_make_rectangular (SCM_I_INUM (y) * SCM_COMPLEX_REAL (x), - SCM_I_INUM (y) * SCM_COMPLEX_IMAG (x)); + { + /* inexact*exact0 is exact 0, per R5RS "Exactness" section */ + if (scm_is_eq (y, SCM_INUM0)) + return y; + return scm_c_make_rectangular (SCM_I_INUM (y) * SCM_COMPLEX_REAL (x), + SCM_I_INUM (y) * SCM_COMPLEX_IMAG (x)); + } else if (SCM_BIGP (y)) { double z = mpz_get_d (SCM_I_BIG_MPZ (y));
_______________________________________________ Bug-guile mailing list Bug-guile@gnu.org http://lists.gnu.org/mailman/listinfo/bug-guile