fixing problem that isinf(-Inf) can be 1 or -1

This commit is contained in:
Taneli Mielikainen committed 2013-08-04 00:21:58 +03:00
1 parent b3bce4d594
commit c5523a17e8
1 file changed
+5 -4
+5 -4
View File
@@ -575,10 +575,11 @@ static int json_object_double_to_json_string(struct json_object* jso,
how to handle these cases as strings */ how to handle these cases as strings */
if(isnan(jso->o.c_double)) if(isnan(jso->o.c_double))
size = snprintf(buf, 128, "NaN"); size = snprintf(buf, 128, "NaN");
else if(isinf(jso->o.c_double) == 1) else if(isinf(jso->o.c_double))
size = snprintf(buf, 128, "Infinity"); if(jso->o.c_double > 0)
else if(isinf(jso->o.c_double) == -1) size = snprintf(buf, 128, "Infinity");
size = snprintf(buf, 128, "-Infinity"); else
size = snprintf(buf, 128, "-Infinity");
else else
size = snprintf(buf, 128, "%f", jso->o.c_double); size = snprintf(buf, 128, "%f", jso->o.c_double);