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

Method multiply

Lib/_pydecimal.py:4924–4954  ·  view source on GitHub ↗

multiply multiplies two operands. If either operand is a special value then the general rules apply. Otherwise, the operands are multiplied together ('long multiplication'), resulting in a number which may be as long as the sum of the lengths of the two operands.

(self, a, b)

Source from the content-addressed store, hash-verified

4922 return a.__neg__(context=self)
4923
4924 def multiply(self, a, b):
4925 """multiply multiplies two operands.
4926
4927 If either operand is a special value then the general rules apply.
4928 Otherwise, the operands are multiplied together
4929 ('long multiplication'), resulting in a number which may be as long as
4930 the sum of the lengths of the two operands.
4931
4932 >>> ExtendedContext.multiply(Decimal('1.20'), Decimal('3'))
4933 Decimal('3.60')
4934 >>> ExtendedContext.multiply(Decimal('7'), Decimal('3'))
4935 Decimal('21')
4936 >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('0.8'))
4937 Decimal('0.72')
4938 >>> ExtendedContext.multiply(Decimal('0.9'), Decimal('-0'))
4939 Decimal('-0.0')
4940 >>> ExtendedContext.multiply(Decimal('654321'), Decimal('654321'))
4941 Decimal('4.28135971E+11')
4942 >>> ExtendedContext.multiply(7, 7)
4943 Decimal('49')
4944 >>> ExtendedContext.multiply(Decimal(7), 7)
4945 Decimal('49')
4946 >>> ExtendedContext.multiply(7, Decimal(7))
4947 Decimal('49')
4948 """
4949 a = _convert_other(a, raiseit=True)
4950 r = a.__mul__(b, context=self)
4951 if r is NotImplemented:
4952 raise TypeError("Unable to convert %s to Decimal" % b)
4953 else:
4954 return r
4955
4956 def next_minus(self, a):
4957 """Returns the largest representable number smaller than a.

Callers 1

test_multiplyMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
__mul__Method · 0.45

Tested by 1

test_multiplyMethod · 0.76