ID EN
Decimal

compare_total

Python 3.11

Compare two operands using their abstract representation rather than their numerical value. Similar to the compare() method, but the result gives a total ordering on Decimal instances. Two Decimal instances with the same numeric value but different representations compare unequal in this ordering:

Syntax

PYTHON
compare_total(other, context=None)

Examples

Example 1
PYTHON
>>> Decimal('12.0').compare_total(Decimal('12'))
Decimal('-1')

See Also

compare() Decimal Decimal