There's more than one way to do things PerlMonks

### Re^2: NaNs are true (NaN == 0 -> true? Really?)

by BrowserUk (Pope)
 on Feb 27, 2011 at 07:48 UTC ( #890380=note: print w/replies, xml ) Need Help??

in reply to Re: NaNs are true (!"NaN")

That's all very logical, except that at the end you seem to have arrived at the situation where you would have an implicit test of a NaN against zero be true?

NaN == 0 -> true cannot be right.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
• Comment on Re^2: NaNs are true (NaN == 0 -> true? Really?)

Replies are listed 'Best First'.
Re^3: NaNs are true (NaN == 0 -> true? Really?)
by pajout (Curate) on Feb 27, 2011 at 11:50 UTC
What about idea that NaN never matches numerical comparison?
```NaN == 0 #false
NaN != 0 #false
NaN == NaN #false
NaN != NaN #false

I think all of those are correct, though not particularly useful. They should also prompt (at least) a warning, though I think a catchable exception is better.

You also have to be careful to distinguish between a variable containing NaN, and a constant NaN I think.

That is, I think the only time any comparison involving a variable containg NaN should result in a true value, is if it is compared against a predefined constant NaN; were one to be provided. Though an isNaN( \$x ) function or equivalenly \$x->isNan() method would serve the same purpose and be less likely to confuse.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Create A New User
Node Status?
node history
Node Type: note [id://890380]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2018-05-23 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (171 votes). Check out past polls.

Notices?