Hi Bill, b...@ccrma.stanford.edu writes:
> But if (* 0 x) is 0, you lose the notion that > (* exact inexact) is inexact. So (* 0 +inf.0) > should be 0.0 or maybe +nan.0. Similarly with > +nan.0, I suppose. No, because (* 0 x) is equivalent to (+), where the x is not an input. In fact, this specific case (multiplication by exact 0) is given as an example where exact 0 may be returned even if the other argument is inexact, by R4RS, R5RS, R6RS, and R7RS. R4RS section 6.5.2, and R5RS section 6.2.2 (Exactness), state: With the exception of 'inexact->exact', the operations described in this section must generally return inexact results when given any inexact arguments. An operation may, however, return an exact result if it can prove that the value of the result is unaffected by the inexactness of its arguments. For example, multiplication of any number by an exact zero may produce an exact zero result, even if the other argument is inexact. R6RS section 11.7.1 (Propagation of exactness and inexactness) states: One general exception to the rule above is that an implementation may return an exact result despite inexact arguments if that exact result would be the correct result for all possible substitutions of exact arguments for the inexact ones. An example is (* 1.0 0) which may return either 0 (exact) or 0.0 (inexact). R7RS section 6.2.2 (Exactness) states: Except for exact, the operations described in this section must generally return inexact results when given any inexact arguments. An operation may, however, return an exact result if it can prove that the value of the result is unaffected by the inexactness of its arguments. For example, multiplication of any number by an exact zero may produce an exact zero result, even if the other argument is inexact. Specifically, the expression (* 0 +inf.0) may return 0, or +nan.0, or report that inexact numbers are not supported, or report that non-rational real numbers are not supported, or fail silently or noisily in other implementation-specific ways. I'm quite sensitive to this issue, so sensitive that I decided to change Guile several years ago so that (* 0 1.0) would return 0.0 instead of 0. My rationale was that if the 1.0 were replaced by +inf.0 or +nan.0, then by IEEE 754 the result should be +nan.0, and therefore that the result was not the same regardless of the value of the inexact argument. I didn't care that R[4567]RS specifically gave this as an example where an exact 0 may be returned, because I judged that it violated the principles of the exactness propagation, and I don't want to return an exact result unless it could in principle be _proved_ to be correct. The new language in R6RS is what changed my mind. In R6RS, you may return an exact result if it "would be the correct result for all possible substitutions of _exact_ arguments for the inexact ones." So, we needn't consider what would happen if +inf.0 or +nan.0 were put in place of the 1.0 in (* 0 1.0), because +inf.0 and +nan.0 are not exact. I think this is the right principle. In mathematics, all real numbers are finite; there are no infinities and no NaNs. I regard the inexact infinities as merely inexact representations of very large finite real numbers. What do you think? Regards, Mark