summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-05-26 16:02:59 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-05-26 16:02:59 (GMT)
commit7f1bf8004de5584b42b1d4771caf12e3302ac506 (patch)
treef9339da7d757c4f51af52733f4551f6dca64d65b /Include
parente73b21240a985583728b40d53f4274bfe406696b (diff)
downloadcpython-7f1bf8004de5584b42b1d4771caf12e3302ac506.zip
cpython-7f1bf8004de5584b42b1d4771caf12e3302ac506.tar.gz
cpython-7f1bf8004de5584b42b1d4771caf12e3302ac506.tar.bz2
Issue #8817: Expose round-to-nearest variant of divmod in _PyLong_Divmod_Near
for use by the datetime module; also refactor long_round to use this function.
Diffstat (limited to 'Include')
-rw-r--r--Include/longobject.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/longobject.h b/Include/longobject.h
index 6bc8275..72bcd98 100644
--- a/Include/longobject.h
+++ b/Include/longobject.h
@@ -101,6 +101,14 @@ PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
*/
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
+/* _PyLong_Divmod_Near. Given integers a and b, compute the nearest
+ integer q to the exact quotient a / b, rounding to the nearest even integer
+ in the case of a tie. Return (q, r), where r = a - q*b. The remainder r
+ will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
+ even.
+*/
+PyAPI_FUNC(PyObject *) _PyLong_Divmod_Near(PyObject *, PyObject *);
+
/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in
base 256, and return a Python long with the same numeric value.
If n is 0, the integer is 0. Else: