PyDocs

Nav

Numeric and Mathematical Modules

Decimal.remainder_near

decimal

method of Decimal
  • Decimal.remainder_near(other, context=None)
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.
1 Example
>>> Decimal(18).remainder_near(Decimal(10))
Decimal('-2')
>>> Decimal(25).remainder_near(Decimal(10))
Decimal('5')
>>> Decimal(35).remainder_near(Decimal(10))
Decimal('-5')
from the Python docs
See Also
No see-alsos for decimal/Decimal.remainder_near
0 Notes
No notes for Decimal.remainder_near