There are a plenty of documents and discussions about float number comparison. But as for me it is not clear can it be always guaranteed that direct comparison of numbers will work on all compilers and platforms?
double x = 1.;
if (1. == x)
{
//do something
}
Will we always enter the if
block?
Edited:
And what comparison here is correct (will work always)? This one?:
double x = 1.;
if (std::abs(1. - x) < std::numeric_limits<double>::epsilon())
{
//do something
}