mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2024-12-27 11:21:02 +08:00
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.
This commit is contained in:
parent
ed971e180e
commit
2083c9e3bf
@ -51,9 +51,9 @@ std::string valueToString( double value )
|
|||||||
{
|
{
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
#ifdef __STDC_SECURE_LIB__ // Use secure version with visual studio 2005 to avoid warning.
|
#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
|
#else
|
||||||
sprintf(buffer, "%.16g", value);
|
sprintf(buffer, "%#.16g", value);
|
||||||
#endif
|
#endif
|
||||||
char* ch = buffer + strlen(buffer) - 1;
|
char* ch = buffer + strlen(buffer) - 1;
|
||||||
if (*ch != '0') return buffer; // nothing to truncate, so save time
|
if (*ch != '0') return buffer; // nothing to truncate, so save time
|
||||||
|
Loading…
x
Reference in New Issue
Block a user