What the hell is NaN?

Someone who was doing a code review for me asked me this question, and how it related to .NET development in general. Funny misconception about NaN, it is not just limited to .NET compatible languages, but is actually an enter computer science concept, to represent an invalid file output based on invalid input operands. I have never used it for anything besides floating point calculations.

The code in question was a condition statement that was taking a SPListItem as a parameter, and was used to check whether the item was a double precision floating number. For this NaN was a definitely a good option! Here is the code:

Yeah, TryParse is MUCH better. Creating an exception is a much more expensive operation that just testing the parse first. If you’ve got a situations where you’re doing a lot of Parse operations, and they’re failing, your app will big significantly slower.

Unless, of course, you want the exception raised – but that’s not the case here…