Issue #16348: Fix incorrect documentation for Decimal.remainder_near.

This commit is contained in:
Mark Dickinson 2012-10-31 19:44:09 +00:00
parent 47fa4d54e8
commit 89e8f54045
1 changed files with 14 additions and 5 deletions

View File

@ -802,12 +802,21 @@ Decimal objects
.. method:: remainder_near(other[, context]) .. method:: remainder_near(other[, context])
Compute the modulo as either a positive or negative value depending on Return the remainder from dividing *self* by *other*. This differs from
which is closest to zero. For instance, ``Decimal(10).remainder_near(6)`` ``self % other`` in that the sign of the remainder is chosen so as to
returns ``Decimal('-2')`` which is closer to zero than ``Decimal('4')``. 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 both are equally close, the one chosen will have the same sign as If the result is zero then its sign will be the sign of *self*.
*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]) .. method:: rotate(other[, context])