Python‎ > ‎decimal‎ > ‎

Decimal.same_quantum()


Definition
Test whether self and other have the same exponent or whether both are NaN.

Syntax
 Decimal(x).same_quantum(y, context=None) 
 
Parameters
x=Decimal
y=integer

Examples
The return are following:
 >>> Decimal(1).same_quantum(0)
True
>>> Decimal(1).same_quantum(1)
True
>>> Decimal(1.00).same_quantum(1)
True
>>> Decimal(1.11).same_quantum(0)
False

The return are equal to:
 >>> import operator
>>> from decimal import Decimal
>>> a=Decimal(1).same_quantum(0)
>>> b=Decimal(1).same_quantum(1)
>>> operator.add(a,b)
2
>>> operator.eq(a,b)
True
>>> operator.floordiv(a,b)
1
>>> operator.ge(a,b)
True
>>> operator.abs(a)
1
>>> operator.abs(b)
1
>>> operator.gt(a,b)
False
>>>


Comments