mardi 30 juin 2015

Is using std::max for comparing two doubles safe?

I know for comparing two doubles we have to do something like this

bool AreSame(double a, double b)
{
    return fabs(a - b) < EPSILON;
}

But I do not know that does std::max compares two doubles the same way or if not the same way safely? That is what will be the answer if I call std::max(0.1,0.11) . I am getting right results but still , I am not sure! Morover I used it last night at codeforces and got my solution accepted!

Aucun commentaire:

Enregistrer un commentaire