From: andrew@rentec.com (Andrew Mullhaupt)
Newsgroups: sci.math
Subject: Re: Not-a-Number
Date: 22 Dec 92 16:14:05 GMT
Organization: Renaissance Technologies Corp., Setauket, NY.

In article <BzGwEC.ALr@unx.sas.com> sasbmt@jjoyce.unx.sas.com (Bruce Tindall) writes:
>
>In article <7ZJ0uB1w165w@west.darkside.com>, susskind@west.darkside.com (Mark Susskind) writes:
>>On to the main purpose.  I believe that it would be pointless to assign
>>Not-a-Number to a variable because one cannot really do any algebra with
>>it.  For a quick example, let x=NaN.  What would be x+1?  What about 2x?
>>And 0x would be every real (or complex) number, would it not?

Actually, there are _conceivable_ uses of NaN assignment, mostly for
testing things. According to IEEE specs, NaN+1 is NaN, 2*NaN is NaN and
so is 0*NaN. The rules for NaN are basically that it represents something
which is _not be a number_, and by implication, any arithmetical operations
applied to it result in similar _not numbers_. Comparison expressions, such
as x > y are _unordered_ if either x or y are NaN, even in the case x = y
where x and y may both be NaN. There is a very good set of rules for these
worked out in the specification for the standard IEEE arithmetic.

>Certain software systems, such as the SAS system, recognize several
>different "not a number" values (which SAS calls "missing values").  
>Usually, any arithmetic operation on a missing value yields a missing 
>value.  There are some circumstances in which missing values are 
>treated as zero instead. 

Which in particular shows that the sensible treatment of missing values
is different than the sensible treatment of non-numbers.

> In sorting and comparisons, missing values 
>sort as less than the "most negative" number (i.e., less than the 
>negative number with the greatest absolute value).

This is also different than not a number.

>These properties, and the ability to select between them, are useful 
>in applications such as survey research (in which you may want to
>distinguish among different kinds of missing data, such as "respondent
>not home," "refused to answer," "didn't know," "not applicable," etc.)
>and statistical analysis.  

Yes, a lot of people think of NaN in this way, and it may be convenient
for implementers to use NaN to support these. However, NaN and missing
values have different semantics, are different things, and ultimately
it pays not to confuse them. Missing values are essentially _unspecified
numbers_ or _numbers to be named later_, and it is acceptable to treat
these values as having those properties common to all numbers. NaN, on
the other hand, does not have these properties. In particular it makes
sense for NaN to be the result of 0.0 / 0.0, but it does not make sense
for this ratio to be thought of as a number which will be subsequently
determined, since contradictions can result from assuming that 0.0 / 0.0
has the properties of a number.

It would be nice to have a standard arithmetic which dealt with unspecified
values, but none exists to my knowledge.

An interesting approach which can support this is interval arithmetic,
which can represent unspecified numbers as maximum ranges.

Later,
Andrew Mullhaupt
Newsgroups: sci.math