[r6rs-discuss] [Formal] Unclear how equality predicates behave on NaN
It seems fairly clear that NaN's should not be considered
strictly a real value, but rather simply "Not a Number";
which only coincidently has been formally defined by IEEE;
thereby may/should be designated as being the result of any
otherwise nondeterministic numerical calculation which may
itself have differing type representations, but otherwise
logically equivalent although comparing numerically distinct.
Thereby for example:
(= ...) numerical value equivalence (within type's precision)
(= -0.0 0 +0.0) => #t
(= 1 (+ 1 0.0)) => #t
(= NaN (/ NaN)) => #f
(eqv? ...) logical value equivalence
(eqv? -0.0 0 +0.0) => #f
(eqv? 1 (+ 1 0.0)) => #f
(eqv? NaN (/ NaN)) => #t
(eq? ...) physical value equivalence
(eq? -0.0 0 +0.0) => {implementation dependent}
(eq? 1 (+ 1 0.0)) => {implementation dependent}
(eq? NaN (/ NaN)) => {implementation dependent}
Thereby it becomes plausible for -0.0 0 +0.0 to
be treated both distinctly and consistently:
(/ +0.0) => +Inf
(/ 0) => NaN
(/ -0.0) => -Inf
Where arguments regarding the efficiency of numerical comparison
utilizing eqv? does not seem legitimate, as the only likely case
where such a comparison is performed is when its differentiation
is explicitly desired; as opposed to the likely case of numerical
comparison utilizing =.
Received on Sat Sep 23 2006 - 23:09:54 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:01 UTC