ID EN
Decimal

compare

Python 3.11

Compare the values of two Decimal instances. compare() returns a Decimal instance, and if either operand is a NaN then the result is a NaN:

Syntax

PYTHON
compare(other, context=None)

Examples

Example 1
PYTHON
a or b is a NaN  ==> Decimal('NaN')
a < b            ==> Decimal('-1')
a == b           ==> Decimal('0')
a > b            ==> Decimal('1')

See Also

compare()