mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-28 16:00:22 +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:
parent
f6bf9ed903
commit
924a59a7b9
1 changed files with 13 additions and 3 deletions
|
@ -4492,7 +4492,12 @@ scm_product (SCM x, SCM y)
|
|||
else if (SCM_REALP (x))
|
||||
{
|
||||
if (SCM_I_INUMP (y))
|
||||
return scm_from_double (SCM_I_INUM (y) * SCM_REAL_VALUE (x));
|
||||
{
|
||||
/* inexact*exact0 => 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 @@ scm_product (SCM x, SCM y)
|
|||
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 => 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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue