The Math “pow” function returns -1.#IND. What kind of error value is -1.#IND and how do I detect the error in an if-statement?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
-1.#INDis the textual representation of NaN on Windows.You can check if a float value is NaN with this small function:
(As @chris notes, if you have a C++11 compliant stdlib, you get
std::isnanin<cmath>.)In normal program flow, you shouldn’t need to worry about NaN as long as you sanity-check your math inputs. Of course, you can also go the other way and just do your math calculations and check against NaN afterwards. 🙂