diff options
author | Raymond Hettinger <python@rcn.com> | 2008-02-01 23:12:19 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-02-01 23:12:19 (GMT) |
commit | 1bcb99a9cbda4d969209ff092b2f13ea2acb5934 (patch) | |
tree | d8b561e4a7a6f24746bc1137e3e1a91e3db7084d /Objects/floatobject.c | |
parent | 1aa8a696f5eab2e1cb173d46306fbd347e8ba724 (diff) | |
download | cpython-1bcb99a9cbda4d969209ff092b2f13ea2acb5934.zip cpython-1bcb99a9cbda4d969209ff092b2f13ea2acb5934.tar.gz cpython-1bcb99a9cbda4d969209ff092b2f13ea2acb5934.tar.bz2 |
Fix int/long typecase. Add check for non-binary floating point.
Diffstat (limited to 'Objects/floatobject.c')
-rw-r--r-- | Objects/floatobject.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 8c7a9a3..5f42ca5 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1158,7 +1158,7 @@ float_as_integer_ratio(PyObject *v, PyObject *unused) { double self; double float_part; - long exponent; + int exponent; PyObject *prev; PyObject *py_exponent = NULL; @@ -1172,6 +1172,13 @@ 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,7 +1209,7 @@ float_as_integer_ratio(PyObject *v, PyObject *unused) /* now self = numerator * 2**exponent exactly; fold in 2**exponent */ denominator = PyLong_FromLong(1); - py_exponent = PyLong_FromLong(labs(exponent)); + py_exponent = PyLong_FromLong(labs((long)exponent)); if (py_exponent == NULL) goto error; INPLACE_UPDATE(py_exponent, long_methods->nb_lshift(denominator, py_exponent)); |