I would like to isolate the behavior when some double value is a NaN or an #INF. To detect a NaN, I test
doubleVal != doubleVal
What about an #INF? Will this test be true when the doubleVal is an #INF?
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.
How about multiplication by
1.once you’re sure it’s notNaN?http://ideone.com/97FNu
You could also use
isinfandisnan, but those might incur some overhead depending on their implementation.A third alternative is using the C max value macros (or equivalent
std::numeric_limits):