From 2083c9e3bfab244a9b93a70fa5f73fe6283b5b32 Mon Sep 17 00:00:00 2001 From: Christopher Dunn Date: Thu, 24 Jan 2008 20:21:11 +0000 Subject: [PATCH] Forgot to add # to %g modifier for sprintf in valueToString for floats. Otherwise no decimal point appears when only zeroes would follow, which changes the type to integer. --- src/lib_json/json_writer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 4129984..9f2145a 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -51,9 +51,9 @@ std::string valueToString( double value ) { char buffer[32]; #ifdef __STDC_SECURE_LIB__ // Use secure version with visual studio 2005 to avoid warning. - sprintf_s(buffer, sizeof(buffer), "%.16g", value); + sprintf_s(buffer, sizeof(buffer), "%#.16g", value); #else - sprintf(buffer, "%.16g", value); + sprintf(buffer, "%#.16g", value); #endif char* ch = buffer + strlen(buffer) - 1; if (*ch != '0') return buffer; // nothing to truncate, so save time