Subj : Re: JSVAL_IS_NUMBER(NaN) == TRUE (!?) To : Justin Fletcher From : Rob Swindell Date : Mon Feb 21 2005 12:42 am Re: Re: JSVAL_IS_NUMBER(NaN) == TRUE (!?) By: Justin Fletcher to netscape.public.mozilla.jseng on Sun Feb 20 2005 04:08 pm > > > > I found it odd that if jsval is NaN, a test of JSVAL_IS_NUMBER(jsval) > > > > evaluate as TRUE. > > > > > > > > > Sure, it's of "number" type (see also typeof(0/0)). > > > > It just seemed illogical (to me) that: > > > > is (not a number) a number? > > > > would evaluate to a true statement. > > As Brendan just said - that's not the question that you're asking with > that statement, though. > > JSVAL_IS_NUMBER(jsval) asks : > > is the intrinsic type of (jsval) a numeric type ? > > NaN is a numeric type value. > > JSVAL_IS_* is used at the lowest level for determining the type of data > represented by a 'jsval'. It places no interpretation on the content of > the data, if it is of that type. That there is particular representation > within the type 'double' which indicates that the value is not a > valid number is irrelevant to it. > > The documentation I have here (albeit a little dated) says this in a > slightly more succinct manner : > > " Use JSVAL_IS_NUMBER to determine if a given JS value, v, is an integer > or double value. If the type tag for v is JSVAL_INT or JSVAL_DOUBLE, > JSVAL_IS_NUMBER evaluates to true. Otherwise, it evaluates to false. " It doesn't mention NaN, but I get the concept. Thanks. :-) digital man Snapple "Real Fact" #81: Alaska has more caribou then people. .