MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / __divmod__

Method __divmod__

tools/python-3.11.9-amd64/Lib/_pydecimal.py:1433–1467  ·  view source on GitHub ↗

Return (self // other, self % other)

(self, other, context=None)

Source from the content-addressed store, hash-verified

1431 return other.__truediv__(self, context=context)
1432
1433 def __divmod__(self, other, context=None):
1434 """
1435 Return (self // other, self % other)
1436 """
1437 other = _convert_other(other)
1438 if other is NotImplemented:
1439 return other
1440
1441 if context is None:
1442 context = getcontext()
1443
1444 ans = self._check_nans(other, context)
1445 if ans:
1446 return (ans, ans)
1447
1448 sign = self._sign ^ other._sign
1449 if self._isinfinity():
1450 if other._isinfinity():
1451 ans = context._raise_error(InvalidOperation, 'divmod(INF, INF)')
1452 return ans, ans
1453 else:
1454 return (_SignedInfinity[sign],
1455 context._raise_error(InvalidOperation, 'INF % x'))
1456
1457 if not other:
1458 if not self:
1459 ans = context._raise_error(DivisionUndefined, 'divmod(0, 0)')
1460 return ans, ans
1461 else:
1462 return (context._raise_error(DivisionByZero, 'x // 0', sign),
1463 context._raise_error(InvalidOperation, 'x % 0'))
1464
1465 quotient, remainder = self._divide(other, context)
1466 remainder = remainder._fix(context)
1467 return quotient, remainder
1468
1469 def __rdivmod__(self, other, context=None):
1470 """Swaps self/other and returns __divmod__."""

Callers 2

__rdivmod__Method · 0.45
divmodMethod · 0.45

Calls 7

_check_nansMethod · 0.95
_isinfinityMethod · 0.95
_divideMethod · 0.95
_convert_otherFunction · 0.85
getcontextFunction · 0.85
_raise_errorMethod · 0.80
_fixMethod · 0.80

Tested by

no test coverage detected