Commit 27c2e880 authored by Ingo van Lil's avatar Ingo van Lil

Fix warning when building with -Wfloat-equal

parent b4b13ee2
......@@ -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(long double x) { return std::isinf(x); }
# 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
inline int getsign(double value) {
if (value < 0) return 1;
......@@ -607,6 +616,10 @@ inline int isinfinity(double x) { return !_finite(x); }
inline int isinfinity(long 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
template <typename Char>
......@@ -2378,7 +2391,7 @@ void BasicWriter<Char>::write_double(
sign = spec.flag(PLUS_FLAG) ? '+' : ' ';
}
if (value != value) {
if (internal::isnotanumber(value)) {
// Format NaN ourselves because sprintf's output is not consistent
// across platforms.
std::size_t nan_size = 4;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment