summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-02 05:11:40 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-02 05:11:40 (GMT)
commit2d1aa3350a40bfd333dac798afdaf2f0b937c2cf (patch)
treea745ca81c29dc7416e6e4bdccc50ed7a696df422 /Objects
parentf9859037fc7e296a6235f27d4ac160197aed828e (diff)
downloadcpython-2d1aa3350a40bfd333dac798afdaf2f0b937c2cf.zip
cpython-2d1aa3350a40bfd333dac798afdaf2f0b937c2cf.tar.gz
cpython-2d1aa3350a40bfd333dac798afdaf2f0b937c2cf.tar.bz2
Simpler solution to handling non-IEEE 754 environments.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/floatobject.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index ca05f0d..5e9371d 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -1173,13 +1173,6 @@ float_as_integer_ratio(PyObject *v, PyObject *unused)
obj = call; \
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);
if (Py_IS_INFINITY(self)) {
@@ -1202,13 +1195,10 @@ float_as_integer_ratio(PyObject *v, PyObject *unused)
for (i=0; i<300 && float_part != floor(float_part) ; i++) {
float_part *= 2.0;
exponent--;
- }
- if (i == 300) {
- /* Could not convert mantissa to an integer */
- Py_INCREF(Py_NotImplemented);
- return Py_NotImplemented;
}
- /* self == float_part * 2**exponent exactly and float_part is integral */
+ /* self == float_part * 2**exponent exactly and float_part is integral.
+ If FLT_RADIX != 2, the 300 steps may leave a tiny fractional part
+ to be truncated by PyLong_FromDouble(). */
numerator = PyLong_FromDouble(float_part);
if (numerator == NULL) goto error;