[r6rs-discuss] [Formal] NaN is not a real number.

From: John Cowan <cowan>
Date: Wed Sep 20 16:42:06 2006

Aubrey Jaffer scripsit:

> (/ 0.0 0.0) is NaN because any finite number satisfies the equation:
>
> z * 0.0 = 0.0.
>
> And that includes any finite complex number! Restricting NaN to be
> real is wrong.

This argument is quite sound theoretically, but will have unfortunate
performance consequences.

> In page 10, "2.4. Infinities and NaNs", I propose the sentence should
> be changed to read:
>
> A NaN is regarded as a complex number whose value is so
> indeterminate that it might represent any complex number.

[snip]

> Because it doesn't participate in the ordering, +nan.0 is not an
> acceptable argument to numerical-ordering predicates (<, <=, >, >=,
> negative?, positive?, etc).

The IEEE standard already defines very specific behavior for these
(equality and ordering predicates return #f whenever a NaN is involved,
e.g.). You would prevent a Scheme system from deferring directly
to the hardware until it had checked that no NaN was being compared.

-- 
John Cowan  cowan_at_ccil.org   http://ccil.org/~cowan
"The exception proves the rule."  Dimbulbs think: "Your counterexample proves
my theory."  Latin students think "'Probat' means 'tests': the exception puts
the rule to the proof."  But legal historians know it means "Evidence for an
exception is evidence of the existence of a rule in cases not excepted from."
Received on Wed Sep 20 2006 - 16:42:01 UTC

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