[r6rs-discuss] [Formal] Unclear how equality predicates behave on NaN

From: John Cowan <cowan>
Date: Wed Sep 20 09:01:24 2006

Per Bothner scripsit:

> Do you have an actual system/example in mind where
> something different than a bit-for-bit comparison
> is preferable?
>
> I'd go so far as to specify:
>
> (eqv? obj1 obje2) is #t if:
>
> obj1 and obj2 are flonums with the same representation
> and are bit-for-bit equal.
>
> (eqv? obj1 obje2) is #f if:
>
> obj1 and obj2 are flonums with the same representation
> and are not bit-for-bit equal.

This would not work reliably in a (hypothetical) system in which
inexact numbers are represented as ratnums with an "inexact" bit
and in which ratnums do not have to be in lowest terms.

But what's really at stake here is that users shouldn't expect
reliable results from eqv? on two NaNs generated by different
processes (where reading "+nan.0" counts as a process), even
on a single system. This conforms to the definition of NaN
in R6RS as a number so inexact that it could be any real number
at all.

> This is a useful definition. It's hard to imagine a
> case where you'd want anything else, assuming flonums
> are they are actually used in today's software and
> hardware.

Not always a good assumption: low-end chips in embedded
systems often have no flonum instructions at all.

-- 
John Cowan    http://ccil.org/~cowan    cowan_at_ccil.org
SAXParserFactory [is] a hideous, evil monstrosity of a class that should
be hung, shot, beheaded, drawn and quartered, burned at the stake,
buried in unconsecrated ground, dug up, cremated, and the ashes tossed
in the Tiber while the complete cast of Wicked sings "Ding dong, the
witch is dead."  --Elliotte Rusty Harold on xml-dev
Received on Wed Sep 20 2006 - 09:01:15 UTC

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