diff options
author | Mark Dickinson <mdickinson@enthought.com> | 2012-10-31 19:45:21 (GMT) |
---|---|---|
committer | Mark Dickinson <mdickinson@enthought.com> | 2012-10-31 19:45:21 (GMT) |
commit | 1d2d007339a64621993fe5ccc8a324f5f1d911f2 (patch) | |
tree | 0225ffc53f91622e9442146cf5abdde52f21ac76 | |
parent | 8781d4a84c778bcb1b11e11877949f06ea4fcf3e (diff) | |
parent | d3405edcdc36b5fefd7ac29649374a4e8c80ad64 (diff) | |
download | cpython-1d2d007339a64621993fe5ccc8a324f5f1d911f2.zip cpython-1d2d007339a64621993fe5ccc8a324f5f1d911f2.tar.gz cpython-1d2d007339a64621993fe5ccc8a324f5f1d911f2.tar.bz2 |
Issue #16348: merge fix from 3.3.
-rw-r--r-- | Doc/library/decimal.rst | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Doc/library/decimal.rst b/Doc/library/decimal.rst index 4a2b2d0..1fc56ad 100644 --- a/Doc/library/decimal.rst +++ b/Doc/library/decimal.rst @@ -750,12 +750,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]) |