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

isinf(x) returns non-zero value if and only if x has an infinite value.  In some implementations isinf(Inf) == -isinf(-Inf) but not always.  This fix takes care of encoding Inf and -Inf correctly independent of the specific implementation of isinf.