diff options
author | Reinier Heeres <reinier@heeres.eu> | 2008-01-26 14:37:06 (GMT) |
---|---|---|
committer | Reinier Heeres <reinier@heeres.eu> | 2008-01-26 14:37:06 (GMT) |
commit | 5786e94b4693a3c5305e4881f556587d5bcc919d (patch) | |
tree | 61f860b7cc87bab9207f3b58c468b77da7a1cbf2 | |
parent | 68f3c107e5cc6edd462bbaa1fa18f6f541bda684 (diff) |
Fix Rational * Decimal bug
-rw-r--r-- | rational.py | 5 |
1 files changed, 4 insertions, 1 deletions
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): |