From 6ecd9e53ce43796a0626d16a89cd6a99b28333cc Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sat, 2 Jan 2010 15:33:56 +0000 Subject: Merged revisions 77234 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r77234 | mark.dickinson | 2010-01-02 14:45:40 +0000 (Sat, 02 Jan 2010) | 7 lines 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. ........ --- Include/longobject.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Include/longobject.h') diff --git a/Include/longobject.h b/Include/longobject.h index 28fb707aa8..2bb1e716af 100644 --- a/Include/longobject.h +++ b/Include/longobject.h @@ -44,13 +44,13 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); /* For use by intobject.c only */ PyAPI_DATA(unsigned char) _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 *); -- cgit v1.2.1