summaryrefslogtreecommitdiffstats
path: root/Doc/library/decimal.rst
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-10-31 19:44:36 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-10-31 19:44:36 (GMT)
commit6ae568b9dfb565430b0761979e56a29e41f75edd (patch)
tree6dffd054c401fdde87afc652a616d84cf436acee /Doc/library/decimal.rst
parent9892f52145a72729253c0e71790feef49d7892af (diff)
downloadcpython-6ae568b9dfb565430b0761979e56a29e41f75edd.zip
cpython-6ae568b9dfb565430b0761979e56a29e41f75edd.tar.gz
cpython-6ae568b9dfb565430b0761979e56a29e41f75edd.tar.bz2
Issue #16348: Fix incorrect documentation for Decimal.remainder_near.
Diffstat (limited to 'Doc/library/decimal.rst')
-rw-r--r--Doc/library/decimal.rst21
1 files changed, 15 insertions, 6 deletions
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst
index ef8b43f..919ebe4 100644
--- a/Doc/library/decimal.rst
+++ b/Doc/library/decimal.rst
@@ -710,12 +710,21 @@ Decimal objects
.. method:: remainder_near(other[, context])
- Compute the modulo as either a positive or negative value depending on
- which is closest to zero. For instance, ``Decimal(10).remainder_near(6)``
- returns ``Decimal('-2')`` which is closer to zero than ``Decimal('4')``.
-
- If both are equally close, the one chosen will have the same sign as
- *self*.
+ Return the remainder from dividing *self* by *other*. This differs from
+ ``self % other`` in that the sign of the remainder is chosen so as to
+ minimize its absolute value. More precisely, the return value is
+ ``self - n * other`` where ``n`` is the integer nearest to the exact
+ value of ``self / other``, and if two integers are equally near then the
+ even one is chosen.
+
+ If the result is zero then its sign will be the sign of *self*.
+
+ >>> Decimal(18).remainder_near(Decimal(10))
+ Decimal('-2')
+ >>> Decimal(25).remainder_near(Decimal(10))
+ Decimal('5')
+ >>> Decimal(35).remainder_near(Decimal(10))
+ Decimal('-5')
.. method:: rotate(other[, context])