diff options
author | Tim King <taking@cs.nyu.edu> | 2010-06-06 16:25:19 +0000 |
---|---|---|
committer | Tim King <taking@cs.nyu.edu> | 2010-06-06 16:25:19 +0000 |
commit | bcf15fb3ff5ec39f50187c157cf1f36daecb4763 (patch) | |
tree | 9b6b382e7bb492e5eb4e9d07185d9492e420253f /src | |
parent | a311ba5ad6b922903fb706c1576d3e5c8eb5c599 (diff) |
Adding += and *= to Rational.
Diffstat (limited to 'src')
-rw-r--r-- | src/util/rational.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/util/rational.h b/src/util/rational.h index 5e187de7f..81e0f7fbd 100644 --- a/src/util/rational.h +++ b/src/util/rational.h @@ -203,10 +203,11 @@ public: } + + Rational operator+(const Rational& y) const{ return Rational( d_value + y.d_value ); } - Rational operator-(const Rational& y) const { return Rational( d_value - y.d_value ); } @@ -218,6 +219,16 @@ public: return Rational( d_value / y.d_value ); } + Rational& operator+=(const Rational& y){ + d_value += y.d_value; + return (*this); + } + + Rational& operator*=(const Rational& y){ + d_value *= y.d_value; + return (*this); + } + /** Returns a string representing the rational in the given base. */ std::string toString(int base = 10) const { return d_value.get_str(base); |