Commit 42a40976 authored by Raymond Hettinger's avatar Raymond Hettinger

Simpler solution to handling non-IEEE 754 environments.

parent a0d9e93b
...@@ -1173,13 +1173,6 @@ float_as_integer_ratio(PyObject *v, PyObject *unused) ...@@ -1173,13 +1173,6 @@ float_as_integer_ratio(PyObject *v, PyObject *unused)
obj = call; \ obj = call; \
Py_DECREF(prev); \ Py_DECREF(prev); \
#ifdef FLT_RADIX
if (FLT_RADIX != 2) {
/* This routine depends on base-2 floating_point. */
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
#endif
CONVERT_TO_DOUBLE(v, self); CONVERT_TO_DOUBLE(v, self);
if (Py_IS_INFINITY(self)) { if (Py_IS_INFINITY(self)) {
...@@ -1203,12 +1196,9 @@ float_as_integer_ratio(PyObject *v, PyObject *unused) ...@@ -1203,12 +1196,9 @@ float_as_integer_ratio(PyObject *v, PyObject *unused)
float_part *= 2.0; float_part *= 2.0;
exponent--; exponent--;
} }
if (i == 300) { /* self == float_part * 2**exponent exactly and float_part is integral.
/* Could not convert mantissa to an integer */ If FLT_RADIX != 2, the 300 steps may leave a tiny fractional part
Py_INCREF(Py_NotImplemented); to be truncated by PyLong_FromDouble(). */
return Py_NotImplemented;
}
/* self == float_part * 2**exponent exactly and float_part is integral */
numerator = PyLong_FromDouble(float_part); numerator = PyLong_FromDouble(float_part);
if (numerator == NULL) goto error; if (numerator == NULL) goto error;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment