From 65cee6ea16dc159ce8d974b729bc6e7855af8646 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Tue, 6 Jan 2015 12:40:36 -0600 Subject: [PATCH 1/2] fix double->string->double round-trip (bump minor ver.) See #98. http://stackoverflow.com/questions/747470/what-is-the-meaning-of-numeric-limitsdoubledigits10/16941784#16941784 --- src/lib_json/json_writer.cpp | 6 +++--- src/test_lib_json/main.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 280f09ed5..5113c38be 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -87,13 +87,13 @@ std::string valueToString(double value) { // visual studio 2005 to // avoid warning. #if defined(WINCE) - len = _snprintf(buffer, sizeof(buffer), "%.16g", value); + len = _snprintf(buffer, sizeof(buffer), "%.17g", value); #else - len = sprintf_s(buffer, sizeof(buffer), "%.16g", value); + len = sprintf_s(buffer, sizeof(buffer), "%.17g", value); #endif #else if (isfinite(value)) { - len = snprintf(buffer, sizeof(buffer), "%.16g", value); + len = snprintf(buffer, sizeof(buffer), "%.17g", value); } else { // IEEE standard states that NaN values will not compare to themselves if (value != value) { diff --git a/src/test_lib_json/main.cpp b/src/test_lib_json/main.cpp index 13fc21df5..51c5e7442 100644 --- a/src/test_lib_json/main.cpp +++ b/src/test_lib_json/main.cpp @@ -926,7 +926,7 @@ JSONTEST_FIXTURE(ValueTest, integers) { JSONTEST_ASSERT_EQUAL(float(uint64ToDouble(Json::UInt64(1) << 63)), val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); - JSONTEST_ASSERT_STRING_EQUAL("9.223372036854776e+18", + JSONTEST_ASSERT_STRING_EQUAL("9.2233720368547758e+18", normalizeFloatingPointStr(val.asString())); // int64 min @@ -974,7 +974,7 @@ JSONTEST_FIXTURE(ValueTest, integers) { JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asDouble()); JSONTEST_ASSERT_EQUAL(-9223372036854775808.0, val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); - JSONTEST_ASSERT_STRING_EQUAL("-9.223372036854776e+18", + JSONTEST_ASSERT_STRING_EQUAL("-9.2233720368547758e+18", normalizeFloatingPointStr(val.asString())); // 10^19 @@ -1065,7 +1065,7 @@ JSONTEST_FIXTURE(ValueTest, integers) { JSONTEST_ASSERT_EQUAL(18446744073709551616.0, val.asDouble()); JSONTEST_ASSERT_EQUAL(18446744073709551616.0, val.asFloat()); JSONTEST_ASSERT_EQUAL(true, val.asBool()); - JSONTEST_ASSERT_STRING_EQUAL("1.844674407370955e+19", + JSONTEST_ASSERT_STRING_EQUAL("1.8446744073709552e+19", normalizeFloatingPointStr(val.asString())); #endif } @@ -1217,7 +1217,7 @@ JSONTEST_FIXTURE(ValueTest, nonIntegers) { normalizeFloatingPointStr(val.asString())); val = Json::Value(1.2345678901234); - JSONTEST_ASSERT_STRING_EQUAL("1.2345678901234", + JSONTEST_ASSERT_STRING_EQUAL("1.2345678901234001", normalizeFloatingPointStr(val.asString())); // A 16-digit floating point number. From 8b489f891ae96d00237292f2446fb1a9645953b7 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Tue, 6 Jan 2015 12:46:17 -0600 Subject: [PATCH 2/2] 1.1.0 <- 1.0.0 --- include/json/version.h | 4 ++-- version | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/json/version.h b/include/json/version.h index 6fe06824d..58fca8a98 100644 --- a/include/json/version.h +++ b/include/json/version.h @@ -4,9 +4,9 @@ #ifndef JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED -# define JSONCPP_VERSION_STRING "1.0.0" +# define JSONCPP_VERSION_STRING "1.1.0" # define JSONCPP_VERSION_MAJOR 1 -# define JSONCPP_VERSION_MINOR 0 +# define JSONCPP_VERSION_MINOR 1 # define JSONCPP_VERSION_PATCH 0 # define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) diff --git a/version b/version index 566d024c7..6314daca8 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.0.0 \ No newline at end of file +1.1.0 \ No newline at end of file