Behaviour of negative zero (-0.0) in comparison with positive zero (+0.0)
In my code,
float f = -0.0; // Negative
and compared with negative zero
f == -0.0f
result will be true.
But
float f = 0.0; // Positive
and compared with negative zero
f == -0.0f
also, result will be true instead of false
Why in both cases result to be true?
Here is a MCVE to test it (live on coliru):
#include
int main()
{
float f = -0.0;
std::cout<<"==== > " << f <
Output:
==== > -0 // Here print negative zero
true