mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Merged revisions 59323-59332 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59324 | georg.brandl | 2007-12-04 17:10:02 +0100 (Tue, 04 Dec 2007) | 3 lines Add "Python on Unix" document, mostly written for GHOP by Shriphani Palakodety. ........ r59325 | facundo.batista | 2007-12-04 17:31:53 +0100 (Tue, 04 Dec 2007) | 3 lines fma speedup by avoiding to create a Context. Thanks Mark Dickinson. ........ r59326 | christian.heimes | 2007-12-04 17:36:20 +0100 (Tue, 04 Dec 2007) | 2 lines Added warning that make install may overwrite or masquerade the default python binary. Use make altinstall instead. A native English speaker may want to rephrase the paragraph. ;) ........ r59327 | georg.brandl | 2007-12-04 17:50:28 +0100 (Tue, 04 Dec 2007) | 2 lines Fix duplicate label and a typo. ........ r59329 | georg.brandl | 2007-12-04 18:46:27 +0100 (Tue, 04 Dec 2007) | 2 lines Add tutorial and examples to logging docs, from GHOP student "oscar8thegrouch". ........ r59332 | christian.heimes | 2007-12-04 19:43:19 +0100 (Tue, 04 Dec 2007) | 1 line These optimizations create smaller and a bit faster code on my machine. I've also disabled an optimization that may be dangerous. Intrinsic functions conflict with errno. ........
This commit is contained in:
parent
43f827b9fa
commit
8b0facf89e
5 changed files with 779 additions and 30 deletions
|
@ -1646,24 +1646,39 @@ class Decimal(object):
|
|||
"""
|
||||
|
||||
other = _convert_other(other, raiseit=True)
|
||||
|
||||
# compute product; raise InvalidOperation if either operand is
|
||||
# a signaling NaN or if the product is zero times infinity.
|
||||
if self._is_special or other._is_special:
|
||||
if context is None:
|
||||
context = getcontext()
|
||||
if self._exp == 'N':
|
||||
return context._raise_error(InvalidOperation, 'sNaN',
|
||||
1, self)
|
||||
if other._exp == 'N':
|
||||
return context._raise_error(InvalidOperation, 'sNaN',
|
||||
1, other)
|
||||
if self._exp == 'n':
|
||||
product = self
|
||||
elif other._exp == 'n':
|
||||
product = other
|
||||
elif self._exp == 'F':
|
||||
if not other:
|
||||
return context._raise_error(InvalidOperation,
|
||||
'INF * 0 in fma')
|
||||
product = Infsign[self._sign ^ other._sign]
|
||||
elif other._exp == 'F':
|
||||
if not self:
|
||||
return context._raise_error(InvalidOperation,
|
||||
'0 * INF in fma')
|
||||
product = Infsign[self._sign ^ other._sign]
|
||||
else:
|
||||
product = _dec_from_triple(self._sign ^ other._sign,
|
||||
str(int(self._int) * int(other._int)),
|
||||
self._exp + other._exp)
|
||||
|
||||
third = _convert_other(third, raiseit=True)
|
||||
|
||||
if context is None:
|
||||
context = getcontext()
|
||||
|
||||
# do self*other in fresh context with no traps and no rounding
|
||||
mul_context = Context(traps=[], flags=[],
|
||||
_rounding_decision=NEVER_ROUND)
|
||||
product = self.__mul__(other, mul_context)
|
||||
|
||||
if mul_context.flags[InvalidOperation]:
|
||||
# reraise in current context
|
||||
return context._raise_error(InvalidOperation,
|
||||
'invalid multiplication in fma',
|
||||
1, product)
|
||||
|
||||
ans = product.__add__(third, context)
|
||||
return ans
|
||||
return product.__add__(third, context)
|
||||
|
||||
def _power_modulo(self, other, modulo, context=None):
|
||||
"""Three argument version of __pow__"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue