Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Classe « Decimal » Python 3.11.3

Méthode decimal.Decimal.compare_total

Signature de la méthode compare_total

def compare_total(self, /, other, context=None) 

Description

help(Decimal.compare_total)

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:

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

Quiet and signaling NaNs are also included in the total ordering. The result
of this function is Decimal('0') if both operands have the same representation,
Decimal('-1') if the first operand is lower in the total order than the second,
and Decimal('1') if the first operand is higher in the total order than the
second operand. See the specification for details of the total order.

This operation is unaffected by context and is quiet: no flags are changed
and no rounding is performed. As an exception, the C version may raise
InvalidOperation if the second operand cannot be converted exactly.