Mercurial > cpython-lru_cache-weakref
diff Objects/floatobject.c @ 45099:d0b31f24694d legacy-trunk
Fix int/long typecase. Add check for non-binary floating point.
| author | Raymond Hettinger <python@rcn.com> |
|---|---|
| date | Fri, 01 Feb 2008 23:12:19 +0000 |
| parents | d12c97cc7467 |
| children | 0b4e8afed663 |
line wrap: on
line diff
--- a/Objects/floatobject.c Fri Feb 01 22:58:17 2008 +0000 +++ b/Objects/floatobject.c Fri Feb 01 23:12:19 2008 +0000 @@ -1158,7 +1158,7 @@ { double self; double float_part; - long exponent; + int exponent; PyObject *prev; PyObject *py_exponent = NULL; @@ -1172,6 +1172,13 @@ 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 @@ /* 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));
