isnan returns an int… nonzero value if arg is NaN, 0 otherwise. Why doesn’t it return a bool? This isn’t some legacy stuff, it’s new with C++11.
isnan returns an int… nonzero value if arg is NaN, 0 otherwise . Why
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.
It is legacy stuff, these are found in
<cmath>, which is the C standard library<math.h>put into thestdnamespace. C doesn’t have a nativebooltype.1Whilst it’s true that these are a C++11 addition, they are essentially pulling in stuff that was added to
<math.h>in C99.1. For those about to complain, C99’s
boolis actually a macro. There is a_Bool, but I guess the C99 authors chose not to use it forisnanet al. in order to retain consistency with other stuff in<math.h>.