mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-07-04 02:37:10 +02:00
address the double to json format accounting for integer side number of digits
This commit is contained in:
parent
b4d2b65841
commit
a89dec25ad
@ -141,8 +141,11 @@ std::string valueToString(double value, bool useSpecialFloats, unsigned int prec
|
||||
char buffer[32];
|
||||
int len = -1;
|
||||
|
||||
int length = (value==0.0)?1:(int)(std::floor(std::log10(std::abs(value)))+1);
|
||||
if (length<1) length=1;
|
||||
|
||||
char formatString[6];
|
||||
sprintf(formatString, "%%.%dg", precision);
|
||||
sprintf(formatString, "%%.%dg", precision-length);
|
||||
|
||||
// Print into the buffer. We need not request the alternative representation
|
||||
// that always has a decimal point because JSON doesn't distingish the
|
||||
|
Loading…
x
Reference in New Issue
Block a user