NaNs are trueby syphilis (Chancellor)
|on Feb 26, 2011 at 13:15 UTC||Need Help??|
syphilis has asked for the
wisdom of the Perl Monks concerning the following question:
A NaN (Not a Number) evaluates as "true" in both Perl and C. That seems a bit counter-intuitive to me. Are there sound, well thought out reasons for having a NaN deemed to be true, or is it just done that way for historical reasons ?
Here's a simple demo:
In both Math::MPFR and Math::MPC, I've overloaded 'bool' so that a NaN is false ... mainly because it struck me as being the logical thing to do.
Now I'm wondering whether that was a mistake. (I couldn't google up any information that helped clarify things for me.)
For a Math::MPFR demo:
Any thoughts ?