1
0
mirror of https://github.com/DaveGamble/cJSON synced 2025-04-24 20:27:55 +00:00
This commit is contained in:
Tanel Dettenborn 2024-09-23 15:21:43 -07:00 committed by GitHub
commit 86c8b87dff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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