MCPcopy Index your code
hub / github.com/python/cpython / same_quantum

Method same_quantum

Lib/_pydecimal.py:2562–2575  ·  view source on GitHub ↗

Return True if self and other have the same exponent; otherwise return False. If either operand is a special value, the following rules are used: * return True if both operands are infinities * return True if both operands are NaNs * otherwise, retur

(self, other, context=None)

Source from the content-addressed store, hash-verified

2560 return ans
2561
2562 def same_quantum(self, other, context=None):
2563 """Return True if self and other have the same exponent; otherwise
2564 return False.
2565
2566 If either operand is a special value, the following rules are used:
2567 * return True if both operands are infinities
2568 * return True if both operands are NaNs
2569 * otherwise, return False.
2570 """
2571 other = _convert_other(other, raiseit=True)
2572 if self._is_special or other._is_special:
2573 return (self.is_nan() and other.is_nan() or
2574 self.is_infinite() and other.is_infinite())
2575 return self._exp == other._exp
2576
2577 def _rescale(self, exp, rounding):
2578 """Rescale self so that the exponent is exp, either by padding with zeros

Callers 2

same_quantumMethod · 0.45

Calls 3

is_nanMethod · 0.95
is_infiniteMethod · 0.95
_convert_otherFunction · 0.85

Tested by 1