[r6rs-discuss] Why are fx+ and fx* restricted to two arguments

From: William D Clinger <will>
Date: Tue Feb 20 10:03:27 2007

I am posting this as an individual member of the Scheme
community. I am not speaking for the R6RS editors.

Earlier in this thread, following a context of fx+ and fx*,
Mikael Tillenius wrote:

> Related to the above, how is ordinary "+" for handled. According to
> IEEE, + (and -, *, /, sqrt) should first be done _exact_ and then
> rounded. Of course IEEE speeks only about binary "+". Do we compute the
> exact sum of all arguments and then round or do we add and round pairs
> of numbers? If so, in what order? Same for "fl+".

Since + accepts exact arguments, inexact arguments, or
any mixture of the two, I began my response by writing:

> When all of the arguments are exact, the result will
> also be exact and the order doesn't matter.

To this, Mikael replied:

> Sorry for nitpicking but this is not true. In fact, the order can
> determine whether the result will be exact or inexact, and in the case
> of inexact it affacts the roundin and whether the result i finite or an Inf.

I'd like to understand your reasoning; if you are right,
then the draft may contain an error. Section 2.2 says:

    If exact numbers are passed to any of the arithmetic
    procedures described in section 9.9, and an exact
    number is returned, then the result is mathematically
    correct.

Section 9.9.1 says that +, -, and * must return the correct
*exact* result provided all of its arguments are exact.
Therefore I believe my statement was correct for those
procedures.

My statement was incorrect for / and sqrt, which you had
mentioned, but I thought your question was about +. At
any rate, section 9.9.1 says that / must return the correct
*exact* result provided all of its arguments are exact and
no divisors are zero. If one or more of its arguments is
an exact zero, then an inexact number (typically infinity
or NaN) may be returned. If that was your nitpick, then
I understand your point.

The sqrt procedure does not have to return an exact result
when its argument is exact, so my statement was false for
sqrt. The sqrt procedure takes only one argument, however,
so I don't see any ordering that could affect the result.
(I understand how the algorithm used to compute inexact
square roots could affect the result.)

The fl+ procedure does not accept exact arguments, so my
statement was vacuously true for fl+.

Will
Received on Tue Feb 20 2007 - 10:03:12 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC