mercredi 2 août 2017

C++ - Why is the following 'if' condition being satisfied unnecessarily when a tuple value is compared to double

I have a tuple defined as: tuple<double, Point, int> best_corr; and a double value called max_val. When I run the following if condition inside a for loop, the condition is satisfied even when both max_val and get<0>(best_corr) have the same value, for example: 1.

if (max_val > get<0>(best_corr))
{
    cout << "\n" << get<0>(best_corr) << " " <<max_val << "\n";
    get<0>(best_corr) = max_val;
    get<1>(best_corr) = max_loc;
    get<2>(best_corr) = i;
}

Why does this happen?

Aucun commentaire:

Enregistrer un commentaire