From murdoch at stats.uwo.ca  Thu Dec 31 22:10:12 2009
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Thu, 31 Dec 2009 16:10:12 -0500
Subject: [Rd] Benefit of treating NA and NaN differently for numerics
In-Reply-To: <1e7471d50912311243s6e681390n1f27ea0fde3c8e3e@mail.gmail.com>
References: <1e7471d50912311243s6e681390n1f27ea0fde3c8e3e@mail.gmail.com>
Message-ID: <4B3D1334.2050206@stats.uwo.ca>

On 31/12/2009 3:43 PM, Saptarshi Guha wrote:
> Hello,
> I notice in main/arithmetic.c, that NA and NaN are encoded
> differently(since every numeric NA comes  from R_NaReal which is
> defined via ValueOfNA)
> . What is the benefit of treating these two differently? Why can't NA
> be a synonym for NaN?

I don't know of any cases where a useful distinction is made between NA 
and NaN, but I suppose it could be useful to know where the bad value 
came from.  R functions rarely generate NaN directly, it usually comes 
from the hardware or runtime library.

And by the way, as the thread containing this message shows,

http://finzi.psych.upenn.edu/R/R-devel/2009-August/054319.html

there are several different encodings which are displayed as NA, and a 
huge number (more than 2^50, I seem to recall) of different encodings 
displayed as NaN.

Duncan Murdoch



[Rd] Benefit of treating NA and NaN differently for numerics
Duncan Murdoch