diff options
Diffstat (limited to 'src/util/integer_cln_imp.h')
-rw-r--r-- | src/util/integer_cln_imp.h | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/util/integer_cln_imp.h b/src/util/integer_cln_imp.h index d13c946de..8c3fc14e5 100644 --- a/src/util/integer_cln_imp.h +++ b/src/util/integer_cln_imp.h @@ -142,25 +142,45 @@ public: } - Integer operator+(const Integer& y) const{ + Integer operator+(const Integer& y) const { return Integer( d_value + y.d_value ); } + Integer& operator+=(const Integer& y) { + d_value += y.d_value; + return *this; + } Integer operator-(const Integer& y) const { return Integer( d_value - y.d_value ); } + Integer& operator-=(const Integer& y) { + d_value -= y.d_value; + return *this; + } Integer operator*(const Integer& y) const { return Integer( d_value * y.d_value ); } + Integer& operator*=(const Integer& y) { + d_value *= y.d_value; + return *this; + } Integer operator/(const Integer& y) const { return Integer( cln::floor1(d_value, y.d_value) ); } + Integer& operator/=(const Integer& y) { + d_value = cln::floor1(d_value, y.d_value); + return *this; + } Integer operator%(const Integer& y) const { return Integer( cln::floor2(d_value, y.d_value).remainder ); } + Integer& operator%=(const Integer& y) { + d_value = cln::floor2(d_value, y.d_value).remainder; + return *this; + } /** Raise this Integer to the power <code>exp</code>. * @@ -208,8 +228,15 @@ public: //friend std::ostream& operator<<(std::ostream& os, const Integer& n); - long getLong() const { return cln::cl_I_to_long(d_value); } - unsigned long getUnsignedLong() const {return cln::cl_I_to_ulong(d_value); } + long getLong() const { + // supposed to throw if not representable in type "long" + return cln::cl_I_to_long(d_value); + } + + unsigned long getUnsignedLong() const { + // supposed to throw if not representable in type "unsigned long" + return cln::cl_I_to_ulong(d_value); + } /** * Computes the hash of the node from the first word of the |