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