mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-13 10:22:55 +01:00
corss compiler isnan
This commit is contained in:
parent
4050143288
commit
6e5e9be736
@ -68,6 +68,25 @@
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#if _MSC_VER >= 1900 && defined(_WIN64)
|
||||
#include <math.h>
|
||||
#define isnan _isnanf
|
||||
#else
|
||||
#include <float.h>
|
||||
#define isnan _isnan
|
||||
#endif
|
||||
#elif __cplusplus >= 201103L
|
||||
#include <cmath>
|
||||
#define isnan std::isnan
|
||||
#else
|
||||
#include <math.h>
|
||||
#if !define(isnan)
|
||||
// IEEE standard states that NaN values will not compare to themselves
|
||||
#define isnan(x) (x!=x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
|
||||
// Disable warning about strdup being deprecated.
|
||||
#pragma warning(disable : 4996)
|
||||
@ -148,7 +167,7 @@ JSONCPP_STRING valueToString(double value, bool useSpecialFloats, unsigned int p
|
||||
}
|
||||
|
||||
} else {
|
||||
// IEEE standard states that NaN values will not compare to themselves
|
||||
|
||||
if (isnan(value)) {
|
||||
len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null");
|
||||
} else if (value < 0) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <iomanip>
|
||||
#include <cmath>
|
||||
|
||||
// Make numeric limits more convenient to talk about.
|
||||
// Assumes int type in 32 bits.
|
||||
@ -2405,7 +2406,7 @@ JSONTEST_FIXTURE(CharReaderAllowSpecialFloatsTest, issue209) {
|
||||
JSONTEST_ASSERT_STRING_EQUAL("", errs);
|
||||
JSONTEST_ASSERT_EQUAL(3u, root.size());
|
||||
double n = root["a"].asDouble();
|
||||
JSONTEST_ASSERT(isnan(n));
|
||||
JSONTEST_ASSERT(std::isnan(n));
|
||||
JSONTEST_ASSERT_EQUAL(std::numeric_limits<double>::infinity(), root.get("b", 0.0));
|
||||
JSONTEST_ASSERT_EQUAL(-std::numeric_limits<double>::infinity(), root.get("c", 0.0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user