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

Method fma

tools/python-3.11.9-amd64/Lib/_pydecimal.py:1932–1974  ·  view source on GitHub ↗

Fused multiply-add. Returns self*other+third with no rounding of the intermediate product self*other. self and other are multiplied together, with no rounding of the result. The third operand is then added to the result, and a single final rounding i

(self, other, third, context=None)

Source from the content-addressed store, hash-verified

1930 return int(self._rescale(0, ROUND_CEILING))
1931
1932 def fma(self, other, third, context=None):
1933 """Fused multiply-add.
1934
1935 Returns self*other+third with no rounding of the intermediate
1936 product self*other.
1937
1938 self and other are multiplied together, with no rounding of
1939 the result. The third operand is then added to the result,
1940 and a single final rounding is performed.
1941 """
1942
1943 other = _convert_other(other, raiseit=True)
1944 third = _convert_other(third, raiseit=True)
1945
1946 # compute product; raise InvalidOperation if either operand is
1947 # a signaling NaN or if the product is zero times infinity.
1948 if self._is_special or other._is_special:
1949 if context is None:
1950 context = getcontext()
1951 if self._exp == 'N':
1952 return context._raise_error(InvalidOperation, 'sNaN', self)
1953 if other._exp == 'N':
1954 return context._raise_error(InvalidOperation, 'sNaN', other)
1955 if self._exp == 'n':
1956 product = self
1957 elif other._exp == 'n':
1958 product = other
1959 elif self._exp == 'F':
1960 if not other:
1961 return context._raise_error(InvalidOperation,
1962 'INF * 0 in fma')
1963 product = _SignedInfinity[self._sign ^ other._sign]
1964 elif other._exp == 'F':
1965 if not self:
1966 return context._raise_error(InvalidOperation,
1967 '0 * INF in fma')
1968 product = _SignedInfinity[self._sign ^ other._sign]
1969 else:
1970 product = _dec_from_triple(self._sign ^ other._sign,
1971 str(int(self._int) * int(other._int)),
1972 self._exp + other._exp)
1973
1974 return product.__add__(third, context)
1975
1976 def _power_modulo(self, other, modulo, context=None):
1977 """Three argument version of __pow__"""

Callers 1

fmaMethod · 0.45

Calls 6

_convert_otherFunction · 0.85
getcontextFunction · 0.85
_dec_from_tripleFunction · 0.85
strFunction · 0.85
_raise_errorMethod · 0.80
__add__Method · 0.45

Tested by

no test coverage detected