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

Method __mul__

Lib/_pydecimal.py:1218–1272  ·  view source on GitHub ↗

Return self * other. (+-) INF * 0 (or its reverse) raise InvalidOperation.

(self, other, context=None)

Source from the content-addressed store, hash-verified

1216 return other.__sub__(self, context=context)
1217
1218 def __mul__(self, other, context=None):
1219 """Return self * other.
1220
1221 (+-) INF * 0 (or its reverse) raise InvalidOperation.
1222 """
1223 other = _convert_other(other)
1224 if other is NotImplemented:
1225 return other
1226
1227 if context is None:
1228 context = getcontext()
1229
1230 resultsign = self._sign ^ other._sign
1231
1232 if self._is_special or other._is_special:
1233 ans = self._check_nans(other, context)
1234 if ans:
1235 return ans
1236
1237 if self._isinfinity():
1238 if not other:
1239 return context._raise_error(InvalidOperation, '(+-)INF * 0')
1240 return _SignedInfinity[resultsign]
1241
1242 if other._isinfinity():
1243 if not self:
1244 return context._raise_error(InvalidOperation, '0 * (+-)INF')
1245 return _SignedInfinity[resultsign]
1246
1247 resultexp = self._exp + other._exp
1248
1249 # Special case for multiplying by zero
1250 if not self or not other:
1251 ans = _dec_from_triple(resultsign, '0', resultexp)
1252 # Fixing in case the exponent is out of bounds
1253 ans = ans._fix(context)
1254 return ans
1255
1256 # Special case for multiplying by power of 10
1257 if self._int == '1':
1258 ans = _dec_from_triple(resultsign, other._int, resultexp)
1259 ans = ans._fix(context)
1260 return ans
1261 if other._int == '1':
1262 ans = _dec_from_triple(resultsign, self._int, resultexp)
1263 ans = ans._fix(context)
1264 return ans
1265
1266 op1 = _WorkRep(self)
1267 op2 = _WorkRep(other)
1268
1269 ans = _dec_from_triple(resultsign, str(op1.int * op2.int), resultexp)
1270 ans = ans._fix(context)
1271
1272 return ans
1273 __rmul__ = __mul__
1274
1275 def __truediv__(self, other, context=None):

Callers 1

multiplyMethod · 0.45

Calls 9

_check_nansMethod · 0.95
_isinfinityMethod · 0.95
_convert_otherFunction · 0.85
getcontextFunction · 0.85
_dec_from_tripleFunction · 0.85
_WorkRepClass · 0.85
strFunction · 0.85
_raise_errorMethod · 0.80
_fixMethod · 0.80

Tested by

no test coverage detected