I assume this just returns an int. Is there anything else going on I should be aware of? C/C++ differences?
float a = 2.5;
!a; // What does this return? Int? Float?
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.
Regarding C++, quoting C++11 §5.3.1/9:
So what’s really relevant here is the behavior of
static_cast<bool>(some_float)– quoting §4.12/1:Putting those together,
2.5fis a non-zero value and will consequently evaluate totrue, which when negated will evaluate tofalse. I.e.,!a==false.Regarding C, quoting C99 §6.5.3.3/5:
I.e. the net result is the same as with C++, excepting the type.