Determine if NSNumber is NaN

Adam Ernst picture Adam Ernst · Apr 5, 2009 · Viewed 24.5k times · Source

How can I determine if a Cocoa NSNumber represents NaN (not a number)?

This emerges, for example, when I parse a string that has an invalid (non-numeric) contents.

Answer

Adam Ernst picture Adam Ernst · Apr 5, 2009

So, I found out that the class property [NSDecimalNumber notANumber] is just for this purpose. In some languages NaN != NaN, but this isn't the case in Cocoa.