summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-01-02 14:45:40 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-01-02 14:45:40 (GMT)
commitd3e323215c6d9f303bf42875f98e365e2ff1734f (patch)
treeed54ecbd1cf3e030812d3b7024a6eeb8b375b7bb /Include
parent5a485c188e56b36b6cfaa2ae942c1ee40b877315 (diff)
downloadcpython-d3e323215c6d9f303bf42875f98e365e2ff1734f.zip
cpython-d3e323215c6d9f303bf42875f98e365e2ff1734f.tar.gz
cpython-d3e323215c6d9f303bf42875f98e365e2ff1734f.tar.bz2
Refactor some longobject internals: PyLong_AsDouble and _PyLong_AsScaledDouble
(the latter renamed to _PyLong_Frexp) now use the same core code. The exponent produced by _PyLong_Frexp now has type Py_ssize_t instead of the previously used int, and no longer needs scaling by PyLong_SHIFT. This frees the math module from having to know anything about the PyLong implementation. This closes issue #5576.
Diffstat (limited to 'Include')
-rw-r--r--Include/longobject.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/Include/longobject.h b/Include/longobject.h
index 0cb8e2f..71815e5 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -33,13 +33,13 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
#define _PyLong_FromSsize_t PyLong_FromSsize_t
PyAPI_DATA(int) _PyLong_DigitValue[256];
-/* _PyLong_AsScaledDouble returns a double x and an exponent e such that
- the true value is approximately equal to x * 2**(SHIFT*e). e is >= 0.
- x is 0.0 if and only if the input is 0 (in which case, e and x are both
- zeroes). Overflow is impossible. Note that the exponent returned must
- be multiplied by SHIFT! There may not be enough room in an int to store
- e*SHIFT directly. */
-PyAPI_FUNC(double) _PyLong_AsScaledDouble(PyObject *vv, int *e);
+/* _PyLong_Frexp returns a double x and an exponent e such that the
+ true value is approximately equal to x * 2**e. e is >= 0. x is
+ 0.0 if and only if the input is 0 (in which case, e and x are both
+ zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is
+ possible if the number of bits doesn't fit into a Py_ssize_t, sets
+ OverflowError and returns -1.0 for x, 0 for e. */
+PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);