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