You might have misremembered this, comparison of a double against itself works. What caught people by surprise is that floating point numbers by default are treated as doubles instead of floats, for example:
float f = 1.1;
if (f == 1.1) {
std::cout << "Things are fine";
}
I was referring to NaN actually, which has the property that x != x. This is usually not a big deal until you use doubles in a generic algorithm that didn't expect it.
good, but not deep enough.
Then how do we go deeper? Give us some links.
Well I don't mean I have "deeper facts" but we could add more to all levels:
You might have misremembered this, comparison of a
doubleagainst itself works. What caught people by surprise is that floating point numbers by default are treated asdoubles instead offloats, for example:You might have been referring to this question: strange output in comparison of float with float literal.
Check this snippet.
The rest I think are good additions to the article.
I was referring to NaN actually, which has the property that x != x. This is usually not a big deal until you use doubles in a generic algorithm that didn't expect it.