help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difference between NaN and NA?


From: David Bateman
Subject: Re: Difference between NaN and NA?
Date: Thu, 08 Apr 2010 09:03:35 +0200
User-agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706)

Jaroslav Hajek wrote:
On Thu, Apr 8, 2010 at 8:13 AM, Matthias Brennwald
<address@hidden> wrote:
Dear all

What is the difference between NaN and NA? I guess there are "different" 
differences, like technical aspects related to the internal programming of Octave (or its 
commercial counterpart), but also related to conventions when/how to use NaN or NA.

I tend to not use NA, and use NaN instead in more or less all situations where 
a variable does not contain a true numerical value. I do this mainly because I 
don't now the difference between the two and therefore decided not to mix them. 
However, I suspect it might be useful to use both in a somehow meaningful 
manner. I'd therefore like to know in which situations you'd use NaN rather 
than NA (and vice versa).



I think that NA was introduced into Octave by D. Bateman to make
importing data from R easier.

No it existed before I touched it..

NA is just a special kind of NaN that is
displayed differently and is detectable by the "isna" function. Most
of Octave is however not aware of NA's and just treats them like NaNs,
so
Exact.. NaN is flagged by a particular exponent in IEEE754, so there are many values of the mantissa that still give a NaN.. What we did was pick one of these to represent the NA value.. Initially the NA value was chosen to be the same as in R. However, when introducing single precision values this value of NA didn't result in an easy conversion of single NA to a double NA value, so I changed the double NA value to facilitate this conversion. However, the load function supports both the old and new NA value.

I asked on the R list if they wanted to change their NA value to allow NA values to be transmitted over a pipe from R to Octave and visa versa, but got no answer

D.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]