[Python-checkins] CVS: python/dist/src/Include longobject.h,2.22,2.23

Tim Peters tim_one@users.sourceforge.net
Mon, 03 Sep 2001 19:50:51 -0700


Update of /cvsroot/python/python/dist/src/Include
In directory usw-pr-cvs1:/tmp/cvs-serv29765/python/Include

Modified Files:
	longobject.h 
Log Message:
Introduce new private API function _PyLong_AsScaledDouble.  Not used yet,
but will be the foundation for Good Things:
+ Speed PyLong_AsDouble.
+ Give PyLong_AsDouble the ability to detect overflow.
+ Make true division of long/long nearly as accurate as possible (no
  spurious infinities or NaNs).
+ Return non-insane results from math.log and math.log10 when passing a
  long that can't be approximated by a double better than HUGE_VAL.


Index: longobject.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Include/longobject.h,v
retrieving revision 2.22
retrieving revision 2.23
diff -C2 -d -r2.22 -r2.23
*** longobject.h	2001/08/29 15:45:32	2.22
--- longobject.h	2001/09/04 02:50:49	2.23
***************
*** 19,22 ****
--- 19,31 ----
  extern DL_IMPORT(long) PyLong_AsLong(PyObject *);
  extern DL_IMPORT(unsigned long) PyLong_AsUnsignedLong(PyObject *);
+ 
+ /* _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. */
+ extern DL_IMPORT(double) _PyLong_AsScaledDouble(PyObject *vv, int *e);
+ 
  extern DL_IMPORT(double) PyLong_AsDouble(PyObject *);
  extern DL_IMPORT(PyObject *) PyLong_FromVoidPtr(void *);