Here is the test program:
void testFunc()
{
double maxValue = DBL_MAX;
double slope = std::numeric_limits<double>::quiet_NaN();
std::cout << "slope is " << slope << std::endl;
std::cout << "maxThreshold is " << maxValue << std::endl;
std::cout << "the_min is " << std::min( slope, maxValue) << std::endl;
std::cout << "the_min is " << std::min( DBL_MAX, std::numeric_limits<double>::quiet_NaN()) << std::endl;
}
int main( int argc, char* argv[] )
{
testFunc();
return 0;
}
In Debug, I get:
slope is nan
maxThreshold is 1.79769e+308
the_min is nan
the_min is 1.79769e+308
In Release, I get:
slope is nan
maxThreshold is 1.79769e+308
the_min is 1.79769e+308
the_min is nan
Why would I get a different result in Release than Debug?
I already checked Stack Overflow post Use of min and max functions in C++, and it does not mention any Release/Debug differences.
I am using Visual Studio 2015.
See Question&Answers more detail:os