https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80137
--- Comment #3 from John Salmon <john.salmon at deshaw dot com> --- It's easy to overthink this. 0.0 is perfectly acceptable, as is any other _RealType in the range [0, 1.). But since rounding was, presumably, to-nearest or up, it's slightly disconcerting that 0.0 is neither near nor up from the "exact" value. How about: if (__builtin_expect(__ret >= _RealType(1), 0)) { #if _GLIBCXX_USE_C99_MATH_TR1 __ret = std::nextafter(_RealType(1), _RealType(0)); #else __ret = _RealType(1) - std::numeric_limits<_RealType>::epsilon()/2.; #endif } I.e., if there's no nextafter, then use numeric_limits::epsilon() to find the value just below 1.0. John Salmon