Python‎ > ‎decimal‎ > ‎

Decimal.compare_total_mag()


Definition
Compare two operands using their abstract representation rather than their value as in compare_total().

Syntax
x.compare_total_mag(y)-> Decimal

Parameters
x & y=Decimals

Examples
The equal to:
 >>> Decimal(2.31).compare_total_mag(Decimal(9.22))
Decimal('-1')
>>> Decimal(12.31).compare_total_mag(Decimal(11.22))
Decimal('1')
>>>

The returns are:
 >>> a= Decimal(2.31).compare_total_mag(Decimal(9.22))
>>> b=Decimal('-1')
>>> operator.ipow(a,b)
Decimal('-1')
>>> operator.truediv(a,b)
Decimal('1')
>>> operator.eq(a,b)
True
>>> operator.sub(a,b)
Decimal('0')
>>> operator.mul(a,b)
Decimal('1')
>>>


Comments