MCPcopy Index your code
hub / github.com/python/cpython / divmod

Method divmod

Lib/_pydecimal.py:4399–4418  ·  view source on GitHub ↗

Return (a // b, a % b). >>> ExtendedContext.divmod(Decimal(8), Decimal(3)) (Decimal('2'), Decimal('2')) >>> ExtendedContext.divmod(Decimal(8), Decimal(4)) (Decimal('2'), Decimal('0')) >>> ExtendedContext.divmod(8, 4) (Decimal('2'), Decimal('0'))

(self, a, b)

Source from the content-addressed store, hash-verified

4397 return r
4398
4399 def divmod(self, a, b):
4400 """Return (a // b, a % b).
4401
4402 >>> ExtendedContext.divmod(Decimal(8), Decimal(3))
4403 (Decimal('2'), Decimal('2'))
4404 >>> ExtendedContext.divmod(Decimal(8), Decimal(4))
4405 (Decimal('2'), Decimal('0'))
4406 >>> ExtendedContext.divmod(8, 4)
4407 (Decimal('2'), Decimal('0'))
4408 >>> ExtendedContext.divmod(Decimal(8), 4)
4409 (Decimal('2'), Decimal('0'))
4410 >>> ExtendedContext.divmod(8, Decimal(4))
4411 (Decimal('2'), Decimal('0'))
4412 """
4413 a = _convert_other(a, raiseit=True)
4414 r = a.__divmod__(b, context=self)
4415 if r is NotImplemented:
4416 raise TypeError("Unable to convert %s to Decimal" % b)
4417 else:
4418 return r
4419
4420 def exp(self, a):
4421 """Returns e ** a.

Callers 1

test_divmodMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
__divmod__Method · 0.45

Tested by 1

test_divmodMethod · 0.76