Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d3405ed

Browse files
committed
Issue #16348: merge fix from 3.2.
2 parents 591c921 + 6ae568b commit d3405ed

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

Doc/library/decimal.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -750,12 +750,21 @@ Decimal objects
750750

751751
.. method:: remainder_near(other[, context])
752752

753-
Compute the modulo as either a positive or negative value depending on
754-
which is closest to zero. For instance, ``Decimal(10).remainder_near(6)``
755-
returns ``Decimal('-2')`` which is closer to zero than ``Decimal('4')``.
756-
757-
If both are equally close, the one chosen will have the same sign as
758-
*self*.
753+
Return the remainder from dividing *self* by *other*. This differs from
754+
``self % other`` in that the sign of the remainder is chosen so as to
755+
minimize its absolute value. More precisely, the return value is
756+
``self - n * other`` where ``n`` is the integer nearest to the exact
757+
value of ``self / other``, and if two integers are equally near then the
758+
even one is chosen.
759+
760+
If the result is zero then its sign will be the sign of *self*.
761+
762+
>>> Decimal(18).remainder_near(Decimal(10))
763+
Decimal('-2')
764+
>>> Decimal(25).remainder_near(Decimal(10))
765+
Decimal('5')
766+
>>> Decimal(35).remainder_near(Decimal(10))
767+
Decimal('-5')
759768

760769
.. method:: rotate(other[, context])
761770

0 commit comments

Comments
 (0)