[r6rs-discuss] Re: [Formal] eq?/eqv? misbehave around NaNs

From: Per Bothner <per>
Date: Fri Nov 24 14:36:40 2006

Alan Watson wrote:
> Per Bothner wrote:
>> eqv? between a single and a double is #f. They're not the same value.
>> End of story.
>
> According to page 35 of the draft, eqv? returns #t if:
>
> Obj1 and obj2 are both inexact numbers, are numerically equal (see =,
> section 9.10), and yield the same results (in the sense of eqv?) when
> passed as arguments to any other procedure that can be defined as a
> finite composition of Scheme's standard arithmetic procedures.
>
> One could imagine an implementation that implemented singles and
> doubles, but promoted singles to doubles whenever they were used in
> arithmetic (in the style of early C compilers) and implemented
> real->single such that it gave a single result. I think on such an
> implementation 1f0 and 1d0 would have to be eqv?.

The wording is wrong. It is either incomplete or non-computable.
The intent, presumably, should be that if the implementation
can *prove* that the values are equivalent then it can/should
return #t. It is implementation-specific how it goes about
doing this, but I would not consider two different
IEEE precisions as being the same value.

>> Just like a list and a vector aren't equal?.
>
> No. Lists and vectors are different types (according to 9.1), but
> singles and doubles are both numbers and as such have the same type.

They have the same *base type*. 9.1. does not say that singles
and double have the same type.
-- 
	--Per Bothner
per_at_bothner.com   http://per.bothner.com/
Received on Fri Nov 24 2006 - 14:37:37 UTC

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