self % other
(self, other, context=None)
| 1474 | return other.__divmod__(self, context=context) |
| 1475 | |
| 1476 | def __mod__(self, other, context=None): |
| 1477 | """ |
| 1478 | self % other |
| 1479 | """ |
| 1480 | other = _convert_other(other) |
| 1481 | if other is NotImplemented: |
| 1482 | return other |
| 1483 | |
| 1484 | if context is None: |
| 1485 | context = getcontext() |
| 1486 | |
| 1487 | ans = self._check_nans(other, context) |
| 1488 | if ans: |
| 1489 | return ans |
| 1490 | |
| 1491 | if self._isinfinity(): |
| 1492 | return context._raise_error(InvalidOperation, 'INF % x') |
| 1493 | elif not other: |
| 1494 | if self: |
| 1495 | return context._raise_error(InvalidOperation, 'x % 0') |
| 1496 | else: |
| 1497 | return context._raise_error(DivisionUndefined, '0 % 0') |
| 1498 | |
| 1499 | remainder = self._divide(other, context)[1] |
| 1500 | remainder = remainder._fix(context) |
| 1501 | return remainder |
| 1502 | |
| 1503 | def __rmod__(self, other, context=None): |
| 1504 | """Swaps self/other and returns __mod__.""" |
no test coverage detected