MCPcopy Index your code
hub / github.com/RustPython/RustPython / multiply

Method multiply

Lib/_pydecimal.py:4921–4951  ·  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

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