What happens when you logical not a float?
问题 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? 回答1: Regarding C++, quoting C++11 §5.3.1/9: The operand of the logical negation operator ! is contextually converted to bool ; its value is true if the converted operand is false and false otherwise. The type of the result is bool . So what's really relevant here is the behavior of static_cast<bool>(some_float) – quoting §4.12/1: