diff --git a/src/util/mpq.cpp b/src/util/mpq.cpp index 6bfd157c4..c52496c4f 100644 --- a/src/util/mpq.cpp +++ b/src/util/mpq.cpp @@ -34,7 +34,7 @@ mpz floor(mpq const & a) { mpz r; mpz_tdiv_q(mpq::zval(r), mpq_numref(a.m_val), mpq_denref(a.m_val)); if (a.is_neg()) - r -= 1; + --r; return r; } @@ -44,7 +44,7 @@ mpz ceil(mpq const & a) { mpz r; mpz_tdiv_q(mpq::zval(r), mpq_numref(a.m_val), mpq_denref(a.m_val)); if (a.is_pos()) - r += 1; + ++r; return r; } diff --git a/src/util/mpz.h b/src/util/mpz.h index cfbe2587e..7be07ebc7 100644 --- a/src/util/mpz.h +++ b/src/util/mpz.h @@ -79,6 +79,11 @@ public: DEFINE_ARITH_OPS(mpz) friend mpz operator%(mpz const & a, mpz const & b); + mpz & operator++() { return operator+=(1); } + mpz & operator--() { return operator-=(1); } + mpz operator++(int) { mpz r(*this); ++(*this); return r; } + mpz operator--(int) { mpz r(*this); --(*this); return r; } + mpz & operator&=(mpz const & o) { mpz_and(m_val, m_val, o.m_val); return *this; } mpz & operator|=(mpz const & o) { mpz_ior(m_val, m_val, o.m_val); return *this; } mpz & operator^=(mpz const & o) { mpz_xor(m_val, m_val, o.m_val); return *this; }