Commit 60d51406 authored by Victor Zverovich's avatar Victor Zverovich

Look for isinf in std namespace too.

parent b09f3713
...@@ -167,13 +167,21 @@ inline unsigned CountDigits(uint64_t n) { ...@@ -167,13 +167,21 @@ inline unsigned CountDigits(uint64_t n) {
} }
#ifndef _MSC_VER #ifndef _MSC_VER
inline int SignBit(double value) { inline int SignBit(double value) {
// When compiled in C++11 mode signbit is no longer a macro but a function // When compiled in C++11 mode signbit is no longer a macro but a function
// defined in namespace std and the macro is undefined. // defined in namespace std and the macro is undefined.
using namespace std; using namespace std;
return signbit(value); return signbit(value);
} }
inline int IsInf(double x) {
using namespace std;
return isinf(x);
}
#else #else
inline int SignBit(double value) { inline int SignBit(double value) {
if (value < 0) return 1; if (value < 0) return 1;
if (value == value) return 0; if (value == value) return 0;
...@@ -181,9 +189,12 @@ inline int SignBit(double value) { ...@@ -181,9 +189,12 @@ inline int SignBit(double value) {
_ecvt(value, 0, &dec, &sign); _ecvt(value, 0, &dec, &sign);
return sign; return sign;
} }
inline int IsInf(double x) { return !_finite(x); }
# undef snprintf # undef snprintf
# define snprintf _snprintf # define snprintf _snprintf
# define isinf(x) (!_finite(x))
#endif #endif
template <typename Char> template <typename Char>
...@@ -618,7 +629,7 @@ void BasicWriter<Char>::FormatDouble( ...@@ -618,7 +629,7 @@ void BasicWriter<Char>::FormatDouble(
return; return;
} }
if (isinf(value)) { if (internal::IsInf(value)) {
// Format infinity ourselves because sprintf's output is not consistent // Format infinity ourselves because sprintf's output is not consistent
// across platforms. // across platforms.
std::size_t size = 4; std::size_t 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