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

Method max

Lib/_pydecimal.py:4819–4844  ·  view source on GitHub ↗

max compares two values numerically and returns the maximum. If either operand is a NaN then the general rules apply. Otherwise, the operands are compared as though by the compare operation. If they are numerically equal then the left-hand operand is chosen as the r

(self, a, b)

Source from the content-addressed store, hash-verified

4817 return a.logical_xor(b, context=self)
4818
4819 def max(self, a, b):
4820 """max compares two values numerically and returns the maximum.
4821
4822 If either operand is a NaN then the general rules apply.
4823 Otherwise, the operands are compared as though by the compare
4824 operation. If they are numerically equal then the left-hand operand
4825 is chosen as the result. Otherwise the maximum (closer to positive
4826 infinity) of the two operands is chosen as the result.
4827
4828 >>> ExtendedContext.max(Decimal('3'), Decimal('2'))
4829 Decimal('3')
4830 >>> ExtendedContext.max(Decimal('-10'), Decimal('3'))
4831 Decimal('3')
4832 >>> ExtendedContext.max(Decimal('1.0'), Decimal('1'))
4833 Decimal('1')
4834 >>> ExtendedContext.max(Decimal('7'), Decimal('NaN'))
4835 Decimal('7')
4836 >>> ExtendedContext.max(1, 2)
4837 Decimal('2')
4838 >>> ExtendedContext.max(Decimal(1), 2)
4839 Decimal('2')
4840 >>> ExtendedContext.max(1, Decimal(2))
4841 Decimal('2')
4842 """
4843 a = _convert_other(a, raiseit=True)
4844 return a.max(b, context=self)
4845
4846 def max_mag(self, a, b):
4847 """Compares the values numerically with their sign ignored.

Callers 1

test_maxMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
maxMethod · 0.45

Tested by 1

test_maxMethod · 0.76