The 0 you display means false in this case, like what the stream shows for false by default. If you want to see it as true or false , use std::boolalpha :
std::cout << std::boolalpha << (a > b) << std::endl;
The serum compares the floating point values, where one of the values โโis nan, then x<y , x>y , x<=y , x>=y and x==y will be evaluated as false, while x!=y will always be true, Andrew Koenig has a good article about this on the Dr Dobbs website.
When you think about this, the result cannot be nan , since comparison operators must return a boolean value that can contain only 2 states.
source share