Skip to content

Commit

Permalink
Forgot to add # to %g modifier for sprintf in valueToString for float…
Browse files Browse the repository at this point in the history
…s. Otherwise no decimal point appears when only zeroes would follow, which changes the type to integer.
  • Loading branch information
cdunn2001 committed Jan 24, 2008
1 parent ed971e1 commit 2083c9e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2083c9e

Please sign in to comment.