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

Method compare_total

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

Compares self to other using the abstract representations. This is not like the standard compare, which use their numerical value. Note that a total ordering is defined for all possible abstract representations.

(self, other, context=None)

Source from the content-addressed store, hash-verified

2943 return self.compare(other, context=context)
2944
2945 def compare_total(self, other, context=None):
2946 """Compares self to other using the abstract representations.
2947
2948 This is not like the standard compare, which use their numerical
2949 value. Note that a total ordering is defined for all possible abstract
2950 representations.
2951 """
2952 other = _convert_other(other, raiseit=True)
2953
2954 # if one is negative and the other is positive, it's easy
2955 if self._sign and not other._sign:
2956 return _NegativeOne
2957 if not self._sign and other._sign:
2958 return _One
2959 sign = self._sign
2960
2961 # let's handle both NaN types
2962 self_nan = self._isnan()
2963 other_nan = other._isnan()
2964 if self_nan or other_nan:
2965 if self_nan == other_nan:
2966 # compare payloads as though they're integers
2967 self_key = len(self._int), self._int
2968 other_key = len(other._int), other._int
2969 if self_key < other_key:
2970 if sign:
2971 return _One
2972 else:
2973 return _NegativeOne
2974 if self_key > other_key:
2975 if sign:
2976 return _NegativeOne
2977 else:
2978 return _One
2979 return _Zero
2980
2981 if sign:
2982 if self_nan == 1:
2983 return _NegativeOne
2984 if other_nan == 1:
2985 return _One
2986 if self_nan == 2:
2987 return _NegativeOne
2988 if other_nan == 2:
2989 return _One
2990 else:
2991 if self_nan == 1:
2992 return _One
2993 if other_nan == 1:
2994 return _NegativeOne
2995 if self_nan == 2:
2996 return _One
2997 if other_nan == 2:
2998 return _NegativeOne
2999
3000 if self < other:
3001 return _NegativeOne
3002 if self > other:

Callers 6

maxMethod · 0.95
minMethod · 0.95
max_magMethod · 0.95
min_magMethod · 0.95
compare_total_magMethod · 0.45
compare_totalMethod · 0.45

Calls 2

_isnanMethod · 0.95
_convert_otherFunction · 0.85

Tested by

no test coverage detected