First page Back Continue Last page Overview Graphics
Comparisons
The comparisons are all built-ins also:
>>> import decimal
>>> x = decimal.Decimal("3.5")
>>> y = decimal.Decimal("4.2")
>>> x == y
False
>>> x > y
False
>>> 3 < x < y
True
>>> min(x,y)
Decimal("3.5")
Notes:
Comparing decimal objects with themselves and with other numeric types is easy as well: just use the normal built-in comparison operators. This also means that you can do things like sorting lists of decimal objects
Oh, and the min() and max() functions work also.