Skip to content

Commit 938f977

Browse files
committed
fix comparison of decimal and integer
1 parent d0d0b9f commit 938f977

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

jepler_udecimal/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5298,16 +5298,13 @@ def _convert_for_comparison(self, other, equality_op=False):
52985298
if isinstance(other, Decimal):
52995299
return self, other
53005300

5301-
# Comparison with a Rational instance (also includes integers):
5302-
# self op n/d <=> self*d op n (for n and d integers, d positive).
5303-
# A NaN or infinity can be left unchanged without affecting the
5304-
# comparison result.
5301+
# Comparison with an integer (we don't have rationals)
53055302
if isinstance(other, int):
53065303
if not self._is_special:
53075304
self = _dec_from_triple(
5308-
self._sign, str(_int(self._int) * other.denominator), self._exp
5305+
self._sign, str(_int(self._int)), self._exp
53095306
)
5310-
return self, Decimal(other.numerator)
5307+
return self, Decimal(other)
53115308

53125309
# Comparisons with float types. == and != comparisons
53135310
# with complex numbers should succeed, returning either True or False

0 commit comments

Comments
 (0)