In IEEE 754 comparing NAN to anything will always yield false
, no matter what it is.
slope > 0; // false
slope < 0; // false
slope == 0; // false
And, more importantly for you
slope < DBL_MAX; // false
DBL_MAX < slope; // false
So it seems that the compiler reorders the parameters/uses >
or <=
instead of <
, and that's why you get the differing results.
For example, those functions could be described as such
Release:
double const& min(double const& l, double const r) {
return l <= r ? l : r;
}
Debug:
double const& min(double const& l, double const& r) {
return r < l ? r : l;
}
The requirements (LessThanComparable) on std::min
aside, those have the same meaning arithmetically. But they yield different results when you use them with NaN.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…