[r6rs-discuss] [Formal] Formal Comment: NaN should be considered a number, not a real

From: John Cowan <cowan>
Date: Fri, 22 Jun 2007 12:55:01 -0400

Arthur Smyles scripsit:

> That is precisely why [NaN] is not a real number. There is no one to one
> correspondence to a line in the case of a NaN

*Every* inexact number represents a segment of the real number line
(or a region of the complex plane, if you prefer), finite in the case
of the rationals, infinite in the case of +inf and -inf and +nan.

Floating-point arithmetic is not real arithmetic; it's not even
associative.

> The question is: what should (nan? nan.0+1i) return. First, NaN is
> created by an indeterminate form. Second, NaN is contagious since any
> mathematical operation that recieves it, must return it. Therefore it
> should return #t.

Currently nan? is only defined on real numbers, and ditto finite?
and infinite? I wouldn't be opposed to extending those to complex
numbers.

> And finally simplifying the complex number constructor to return a NaN
> if either the real or imaginary parts are NaN.

That's where the sticky bit is. Instead of compnum addition involving
adding real parts and imaginary parts, there now have to be complicated
and annoying NaN checks. The whole point of NaN is *not to have to
check* until the inner loop finishes: only then do you find out whether
your results are rubbish.

-- 
A: "Spiro conjectures Ex-Lax."                  John Cowan
Q: "What does Pat Nixon frost her cakes with?"  cowan at ccil.org
  --"Jeopardy" for generative semanticists      http://www.ccil.org/~cowan
Received on Fri Jun 22 2007 - 12:55:01 UTC

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