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

Method __mul__

tools/python-3.11.9-amd64/Lib/_pydecimal.py:1277–1331  ·  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

1275 return other.__sub__(self, context=context)
1276
1277 def __mul__(self, other, context=None):
1278 """Return self * other.
1279
1280 (+-) INF * 0 (or its reverse) raise InvalidOperation.
1281 """
1282 other = _convert_other(other)
1283 if other is NotImplemented:
1284 return other
1285
1286 if context is None:
1287 context = getcontext()
1288
1289 resultsign = self._sign ^ other._sign
1290
1291 if self._is_special or other._is_special:
1292 ans = self._check_nans(other, context)
1293 if ans:
1294 return ans
1295
1296 if self._isinfinity():
1297 if not other:
1298 return context._raise_error(InvalidOperation, '(+-)INF * 0')
1299 return _SignedInfinity[resultsign]
1300
1301 if other._isinfinity():
1302 if not self:
1303 return context._raise_error(InvalidOperation, '0 * (+-)INF')
1304 return _SignedInfinity[resultsign]
1305
1306 resultexp = self._exp + other._exp
1307
1308 # Special case for multiplying by zero
1309 if not self or not other:
1310 ans = _dec_from_triple(resultsign, '0', resultexp)
1311 # Fixing in case the exponent is out of bounds
1312 ans = ans._fix(context)
1313 return ans
1314
1315 # Special case for multiplying by power of 10
1316 if self._int == '1':
1317 ans = _dec_from_triple(resultsign, other._int, resultexp)
1318 ans = ans._fix(context)
1319 return ans
1320 if other._int == '1':
1321 ans = _dec_from_triple(resultsign, self._int, resultexp)
1322 ans = ans._fix(context)
1323 return ans
1324
1325 op1 = _WorkRep(self)
1326 op2 = _WorkRep(other)
1327
1328 ans = _dec_from_triple(resultsign, str(op1.int * op2.int), resultexp)
1329 ans = ans._fix(context)
1330
1331 return ans
1332 __rmul__ = __mul__
1333
1334 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