mirror of
https://github.com/DaveGamble/cJSON
synced 2025-04-24 20:27:55 +00:00
Merge 741e30cff6
into 12c4bf1986
This commit is contained in:
commit
86c8b87dff
7
cJSON.c
7
cJSON.c
@ -591,7 +591,12 @@ static cJSON_bool print_number(const cJSON * const item, printbuffer * const out
|
||||
length = sprintf((char*)number_buffer, "%1.15g", d);
|
||||
|
||||
/* Check whether the original double can be recovered */
|
||||
if ((sscanf((char*)number_buffer, "%lg", &test) != 1) || !compare_double((double)test, d))
|
||||
if (sscanf((char*)number_buffer, "%lg", &test) != 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!compare_double((double)test, d))
|
||||
{
|
||||
/* If not, print with 17 decimal places of precision */
|
||||
length = sprintf((char*)number_buffer, "%1.17g", d);
|
||||
|
Loading…
Reference in New Issue
Block a user