mirror of
https://github.com/DaveGamble/cJSON.git
synced 2023-08-10 21:13:26 +03:00
if it's a big number, but still an integer, print it exactly!
git-svn-id: http://svn.code.sf.net/p/cjson/code@18 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
parent
0dbe29ffe8
commit
501ff3b3d0
3
cJSON.c
3
cJSON.c
@ -121,7 +121,8 @@ static char *print_number(cJSON *item)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
str=(char*)cJSON_malloc(64); // This is a nice tradeoff.
|
str=(char*)cJSON_malloc(64); // This is a nice tradeoff.
|
||||||
if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
|
if (fabs(floor(d)-d)<=DBL_EPSILON) sprintf(str,"%.0f",d);
|
||||||
|
else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d);
|
||||||
else sprintf(str,"%f",d);
|
else sprintf(str,"%f",d);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
Loading…
Reference in New Issue
Block a user