[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] EQV? on numbers should be based on operational equivalence
Alex Shinn scripsit:
> We haven't generally made a distinction for a result being
> "implementation-defined", simply saying "unspecified." Thus
> with either the R3RS or current R7RS, for the specific question
>
> (= 0.0 -0.0) => ?
>
> the ? would be written "unspecified". That is, the semantics
> are clearly defined by the standard but the effect varies per
> implementation, so from a point of view of portability you
> cannot reliably get a consistent result from this expression.
It's more complex than that. There are three possibilities.
1) The implementation does not support -0.0 at all. If not, then the
value of the expression `(eqv? 0.0 -0.0)` is always going to be #t.
Both R5RS (sub silentio) and R6RS (explicitly) allow this.
2) The implementation supports -0.0 as numerically distinct from 0.0, but
`(eqv? 0.0 -0.0)` returns #t. This is the natural interpretation of R5RS,
because that standard defers to = when it is comparing inexact numbers,
and everybody agrees that (= 0.0 -0.0) is #t.
3) The implementation supports -0.0 as numerically distinct from 0.0,
but `(eqv? 0.0 -0.0)` returns #f. This is what R6RS requires.
Therefore, R7RS requires (sub silentio) that if 0.0 and -0.0 are not
mathematically distinct, then `eqv?` must return #t, but explicitly
allows either #t or #f otherwise.
--
John Cowan cowan@x http://ccil.org/~cowan
The present impossibility of giving a scientific explanation is no proof
that there is no scientific explanation. The unexplained is not to be
identified with the unexplainable, and the strange and extraordinary
nature of a fact is not a justification for attributing it to powers
above nature. --The Catholic Encyclopedia, s.v. "telepathy" (1913)
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports