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.
........
diff --git a/Include/longobject.h b/Include/longobject.h
index 28fb707..2bb1e71 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -44,13 +44,13 @@
 /* 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 *);