Alan Watson wrote:
> Be careful. A single and a double can easily have the same *value*, even
> though their *representations* are different.
They can be the same *number*, but not the same *value*. Just
like the integer 1 and inexact/float 1.0.
> Can you come up with a description of eqv? that obtains the behaviour
> you want on singles and doubles without reference to their
> representation? (Not refering to "representation" is important because
> one could implement doubles using different representations, say boxed
> and unboxed, and one presumably wants (eqv? 0.0d0 0.0d0) to always be
> true.)
I'm not sure one can, but that's not needed. One can say:
A flonum can only be eqv? another flonum.
A flonum that is represented by an IEEE binary ?oating
point number [compare 16.4 page 100, though I would refer to a
later IEEE standard that also covers decimal floating point]
is only eqv? another flonum that uses the same representation,
and that is bit-for-bit equal, except that an implementation
may optionally treat all NaN values of the same representation as
eqv? if they are otherwise indistinguishable by procedures in [R6RS].
--
--Per Bothner
per_at_bothner.com http://per.bothner.com/
Received on Sat Nov 25 2006 - 02:11:09 UTC