mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-26 00:21:13 +00:00
Fix warning when building with -Wfloat-equal
This commit is contained in:
parent
b4b13ee2b8
commit
27c2e880d0
15
format.h
15
format.h
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user