From: Taneli Mielikainen Date: Sat, 3 Aug 2013 21:21:58 +0000 (+0300) Subject: fixing problem that isinf(-Inf) can be 1 or -1 X-Git-Tag: json-c-0.12-20140410~33^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F93%2Fhead;p=thirdparty%2Fjson-c.git fixing problem that isinf(-Inf) can be 1 or -1 --- diff --git a/json_object.c b/json_object.c index e12c4407..b63faa48 100644 --- a/json_object.c +++ b/json_object.c @@ -575,10 +575,11 @@ static int json_object_double_to_json_string(struct json_object* jso, how to handle these cases as strings */ if(isnan(jso->o.c_double)) size = snprintf(buf, 128, "NaN"); - else if(isinf(jso->o.c_double) == 1) - size = snprintf(buf, 128, "Infinity"); - else if(isinf(jso->o.c_double) == -1) - size = snprintf(buf, 128, "-Infinity"); + else if(isinf(jso->o.c_double)) + if(jso->o.c_double > 0) + size = snprintf(buf, 128, "Infinity"); + else + size = snprintf(buf, 128, "-Infinity"); else size = snprintf(buf, 128, "%f", jso->o.c_double);