On Unix system, you'll have the isnan method at your disposal ( math.h ). You'll need to check for both infinity as well as not-a-number. Use a logical OR. That's a caveat!
- Take the square root of a negative number.
- Check for: isnan(MyNumber) || isinf(MyNumber)
Check out this:
http://math.nist.gov/tnt/index.html
Download that tool, since the C++ standard does not yet defined functions to classify NaN's. At least you'll have something to work with.