瀏覽代碼

get rid of isnormal test!!

Dave Gamble 9 年之前
父節點
當前提交
2fe50bd557
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      cJSON.c

+ 1 - 1
cJSON.c

@@ -166,7 +166,7 @@ static char *print_number(cJSON *item,printbuffer *p)
 		else	str=(char*)cJSON_malloc(64);	/* This is a nice tradeoff. */
 		if (str)
 		{
-			if (!isnormal(d))											sprintf(str,"null");
+			if (d*0!=0)													sprintf(str,"null");	/* This checks for NaN and Infinity */
 			else if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60)	sprintf(str,"%.0f",d);
 			else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9)					sprintf(str,"%e",d);
 			else														sprintf(str,"%f",d);