[Numpy-discussion] isinf raises in inf
Pauli Virtanen
pav at iki.fi
Fri Jul 16 04:27:14 EDT 2010
Thu, 15 Jul 2010 19:09:15 -0600, Charles R Harris wrote:
[clip]
> PS, of course we should fix the macro also. Since the bit values of +/-
> infinity are known we should be able to define them as constants using a
> couple of ifdefs and unions.
We already do that, NPY_INFINITY and -NPY_INFINITY.
[clip]
> int
> (isinf)(double x)
> {
> if ((-1.0 < x) && (x < 1.0)) /* x is small, and thus finite */
> return (0);
> else if ((x + x) == x) /* only true if x == Infinity */
> return (1);
> else /* must be finite (normal or subnormal), or NaN */
> return (0);
> }
This function can generate overflows, for example for
x = 0.6 * np.finfo(np.float64).max
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list