Add missing operators
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
5c76cac9b1
commit
e7bfd9a77d
2 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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; }
|
||||
|
|
Loading…
Reference in a new issue