Handle products with exact 0 differently
* libguile/numbers.c (scm_product): Handle exact 0 differently. A
product containing an exact 0 now returns an exact 0 if and only if
the other arguments are all exact. An inexact zero is returned if and
only if the other arguments are all finite but not all exact. If an
infinite or NaN value is present, a NaN value is returned.
Previously, any product containing an exact 0 yielded an exact 0,
regardless of the other arguments.
A note on the rationale for (* 0 0.0) returning 0.0 and not exact 0:
The exactness propagation rules allow us to return an exact result in
the presence of inexact arguments only if the values of the inexact
arguments do not affect the result. In this case, the value of the
inexact argument _does_ affect the result, because an infinite or NaN
value causes the result to be a NaN.
A note on the rationale for (* 0 +inf.0) being a NaN and not exact 0:
The R6RS requires that (/ 0 0.0) return a NaN value, and that (/ 0.0)
return +inf.0. We would like (/ x y) to be the same as (* x (/ y)),
and in particular, for (/ 0 0.0) to be the same as (* 0 (/ 0.0)),
which reduces to (* 0 +inf.0). Therefore (* 0 +inf.0) should return
a NaN.
* test-suite/tests/numbers.test: Add many multiplication tests.
* NEWS: Add NEWS entry.