
'Afternoon, The usual std::min and std::max prefer numbers over NaNs per http://en.wikipedia.org/wiki/IEEE_754_revision#min_and_max. POSIX's fmin(3) does as well. Can anyone suggest a better implementation (chained ternary complaints aside) for a NaN-preferring min or max than brute force things akin to template<class T> inline const T& minnan(const T& a, const T& b) { return UNLIKELY((boost::math::isnan)(a)) ? a : (a < b) ? a : b; } where UNLIKELY is a small macro telling the compiler to generate code expecting that the boost::math::isnan test fails? The need arises in a numerical simulation where I want to gradually accumulate a global minimum where throwing away NaNs ("windowing" in IEEE 754 revision-speak) is the unacceptable. Thanks, Rhys