mirror of https://github.com/Icinga/icinga2.git
parent
6482fcec59
commit
bb0b618e71
|
@ -127,12 +127,20 @@ static char *print_number(cJSON *item)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
str=(char*)cJSON_malloc(64 + (int)log10(fabs(d))); /* This is a nice tradeoff. */
|
if (d != d)
|
||||||
if (str)
|
|
||||||
{
|
{
|
||||||
if (d != d) strcpy(str, "0");
|
str=(char*)cJSON_malloc(2);
|
||||||
else if (fabs(floor(d)-d)<=DBL_EPSILON) sprintf(str,"%.0f",d);
|
if (str)
|
||||||
else sprintf(str,"%.*e",(int)log10(d) + 6,d);
|
strcpy(str, "0");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
str = (char*)cJSON_malloc(64 + (int)log10(fabs(d))); /* This is a nice tradeoff. */
|
||||||
|
if (str)
|
||||||
|
{
|
||||||
|
if (fabs(floor(d) - d) <= DBL_EPSILON) sprintf(str, "%.0f", d);
|
||||||
|
else sprintf(str, "%.*e", (int)log10(d) + 6, d);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
|
|
Loading…
Reference in New Issue