[r6rs-discuss] Re: [Formal] eq?/eqv? misbehave around NaNs
alan at alan-watson.org
Fri Nov 24 14:01:12 EST 2006
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?.
> "same bit representation" *assuming* they're the same type;
> #f if they're different types.
> 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.
More information about the r6rs-discuss