From: Tim King Date: Sun, 6 Jun 2010 16:25:19 +0000 (+0000) Subject: Adding += and *= to Rational. X-Git-Tag: cvc5-1.0.0~8994 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bcf15fb3ff5ec39f50187c157cf1f36daecb4763;p=cvc5.git Adding += and *= to Rational. --- 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);