self % other
(self, other, context=None)
| 1418 | return other.__divmod__(self, context=context) |
| 1419 | |
| 1420 | def __mod__(self, other, context=None): |
| 1421 | """ |
| 1422 | self % other |
| 1423 | """ |
| 1424 | other = _convert_other(other) |
| 1425 | if other is NotImplemented: |
| 1426 | return other |
| 1427 | |
| 1428 | if context is None: |
| 1429 | context = getcontext() |
| 1430 | |
| 1431 | ans = self._check_nans(other, context) |
| 1432 | if ans: |
| 1433 | return ans |
| 1434 | |
| 1435 | if self._isinfinity(): |
| 1436 | return context._raise_error(InvalidOperation, 'INF % x') |
| 1437 | elif not other: |
| 1438 | if self: |
| 1439 | return context._raise_error(InvalidOperation, 'x % 0') |
| 1440 | else: |
| 1441 | return context._raise_error(DivisionUndefined, '0 % 0') |
| 1442 | |
| 1443 | remainder = self._divide(other, context)[1] |
| 1444 | remainder = remainder._fix(context) |
| 1445 | return remainder |
| 1446 | |
| 1447 | def __rmod__(self, other, context=None): |
| 1448 | """Swaps self/other and returns __mod__.""" |
no test coverage detected