From 5786e94b4693a3c5305e4881f556587d5bcc919d Mon Sep 17 00:00:00 2001 From: Reinier Heeres Date: Sat, 26 Jan 2008 14:37:06 +0000 Subject: Fix Rational * Decimal bug --- diff --git a/rational.py b/rational.py index 0a5571a..564d4d9 100644 --- a/rational.py +++ b/rational.py @@ -18,6 +18,7 @@ # 2007-07-03: rwh, first version import types +from decimal import Decimal import logging _logger = logging.getLogger('Rational') @@ -101,8 +102,10 @@ class Rational: ret = Rational(self.n * rval.n, self.d * rval.d) elif type(rval) is types.IntType or type(rval) is types.LongType: ret = Rational(self.n * rval, self.d) + elif isinstance(rval, Decimal): + ret = rval * Decimal(str(float(self))) else: - ret = float(self) * rval + ret = rval * float(self) return ret def __rmul__(self, lval): -- cgit v0.9.1