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:
Christopher Dunn 2008-01-24 20:21:11 +00:00
parent ed971e180e
commit 2083c9e3bf

View File

@ -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