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: Jaroslav Hajek
Subject: Re: Difference between NaN and NA?
Date: Thu, 8 Apr 2010 08:35:57 +0200

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. 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

octave:1> NA + NaN
ans = NaN
octave:2> NaN + NA
ans = NA

etc. It should normally be safe to just ignore the existence of NAs,
except if you convert numbers to strings and you rely on NaNs being
converted in a particular manner.

Few codes seem to use this feature.

-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz



reply via email to

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