address the double to json accounting for large double (thousands, millions, billions) and avoid "negative mantissa length"

This commit is contained in:
Stefano Fiorentino 2016-02-12 11:45:56 +01:00
parent a89dec25ad
commit 2f8b38266c

View File

@ -145,7 +145,14 @@ std::string valueToString(double value, bool useSpecialFloats, unsigned int prec
if (length<1) length=1;
char formatString[6];
if (length<precision)
{
sprintf(formatString, "%%.%dg", precision-length);
}
else
{
sprintf(formatString, "%%g");
}
// Print into the buffer. We need not request the alternative representation
// that always has a decimal point because JSON doesn't distingish the