Fix warning when building with -Wfloat-equal

This commit is contained in:
Ingo van Lil 2015-11-02 13:43:46 +01:00
parent b4b13ee2b8
commit 27c2e880d0

View File

@ -594,6 +594,15 @@ inline int isinfinity(long double x) { return isinf(x); }
inline int isinfinity(double x) { return std::isinf(x); } inline int isinfinity(double x) { return std::isinf(x); }
inline int isinfinity(long double x) { return std::isinf(x); } inline int isinfinity(long double x) { return std::isinf(x); }
# endif # endif
// Portable version of isnan.
# ifdef isnan
inline int isnotanumber(double x) { return isnan(x); }
inline int isnotanumber(long double x) { return isnan(x); }
# else
inline int isnotanumber(double x) { return std::isnan(x); }
inline int isnotanumber(long double x) { return std::isnan(x); }
# endif
#else #else
inline int getsign(double value) { inline int getsign(double value) {
if (value < 0) return 1; if (value < 0) return 1;
@ -607,6 +616,10 @@ inline int isinfinity(double x) { return !_finite(x); }
inline int isinfinity(long double x) { inline int isinfinity(long double x) {
return !_finite(static_cast<double>(x)); return !_finite(static_cast<double>(x));
} }
inline int isnotanumber(double x) { return _isnan(x); }
inline int isnotanumber(long double x) {
return _isnan(static_cast<double>(x));
}
#endif #endif
template <typename Char> template <typename Char>
@ -2378,7 +2391,7 @@ void BasicWriter<Char>::write_double(
sign = spec.flag(PLUS_FLAG) ? '+' : ' '; sign = spec.flag(PLUS_FLAG) ? '+' : ' ';
} }
if (value != value) { if (internal::isnotanumber(value)) {
// Format NaN ourselves because sprintf's output is not consistent // Format NaN ourselves because sprintf's output is not consistent
// across platforms. // across platforms.
std::size_t nan_size = 4; std::size_t nan_size = 4;