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

Method same_quantum

Lib/_pydecimal.py:5369–5391  ·  view source on GitHub ↗

Returns True if the two operands have the same exponent. The result is never affected by either the sign or the coefficient of either operand. >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001')) False >>> ExtendedContext.same_quantum(Decimal(

(self, a, b)

Source from the content-addressed store, hash-verified

5367 return a.rotate(b, context=self)
5368
5369 def same_quantum(self, a, b):
5370 """Returns True if the two operands have the same exponent.
5371
5372 The result is never affected by either the sign or the coefficient of
5373 either operand.
5374
5375 >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.001'))
5376 False
5377 >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('0.01'))
5378 True
5379 >>> ExtendedContext.same_quantum(Decimal('2.17'), Decimal('1'))
5380 False
5381 >>> ExtendedContext.same_quantum(Decimal('Inf'), Decimal('-Inf'))
5382 True
5383 >>> ExtendedContext.same_quantum(10000, -1)
5384 True
5385 >>> ExtendedContext.same_quantum(Decimal(10000), -1)
5386 True
5387 >>> ExtendedContext.same_quantum(10000, Decimal(-1))
5388 True
5389 """
5390 a = _convert_other(a, raiseit=True)
5391 return a.same_quantum(b)
5392
5393 def scaleb (self, a, b):
5394 """Returns the first operand after adding the second value its exp.

Callers 1

test_same_quantumMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
same_quantumMethod · 0.45

Tested by 1

test_same_quantumMethod · 0.76