help-octave
[Top][All Lists]
Advanced

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

Re: isnumeric (NaN) = true !?


From: David Grundberg
Subject: Re: isnumeric (NaN) = true !?
Date: Thu, 25 Mar 2010 17:43:13 +0100
User-agent: Thunderbird 2.0.0.23 (X11/20090812)

Søren Hauberg wrote:
tor, 25 03 2010 kl. 14:40 +0100, skrev Matthias Brennwald:
What is the logic behind this:

        isnumeric (NaN) = 1

I believe that "NaN" means "not a number". How can something which is
"not a number" be numeric? What is the logic behind this?

I wouldn't exactly call it logic, but one reason for this behaviour is
that Matlab does the same.

In general, when it comes to NaN's you have to deal with them using
'isnan'.

Søren

You're all confusing the terminology here. Stop trying to apply common sense and intuition, nothing good has ever come out of it. (joke) The isnumeric function checks the *class* of a variable and has nothing to do with the *value* of the variable. One class that isnumeric considers true is "double". "Not a number" is a value, not a class. Since the value "not a number" is of class "double", the variable is numeric.

hth,
David



reply via email to

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