GmpInt& GmpInt::operator-=(long value) { copyIfShared(); if(value >= 0) mpz_sub_ui(mData->mInteger, mData->mInteger, value); else mpz_add_ui(mData->mInteger, mData->mInteger, -value); return *this; }
GmpInt& GmpInt::operator/=(long value) { copyIfShared(); if(value >= 0) mpz_tdiv_q_ui(mData->mInteger, mData->mInteger, value); else { mpz_neg(mData->mInteger, mData->mInteger); mpz_tdiv_q_ui(mData->mInteger, mData->mInteger, -value); } return *this; }
GmpInt& GmpInt::operator%=(const GmpInt& rhs) { copyIfShared(); if(operator<(0)) { negate(); mpz_mod(mData->mInteger, mData->mInteger, rhs.mData->mInteger); negate(); } else { mpz_mod(mData->mInteger, mData->mInteger, rhs.mData->mInteger); } return *this; }
GmpInt& GmpInt::operator%=(long value) { copyIfShared(); if(value < 0) value = -value; if(operator<(0)) { negate(); mpz_mod_ui(mData->mInteger, mData->mInteger, value); negate(); } else { mpz_mod_ui(mData->mInteger, mData->mInteger, value); } return *this; }
void MpfrFloat::abs() { copyIfShared(); mpfr_abs(mData->mFloat, mData->mFloat, GMP_RNDN); }
//=========================================================================== // Modifying functions //=========================================================================== void MpfrFloat::negate() { copyIfShared(); mpfr_neg(mData->mFloat, mData->mFloat, GMP_RNDN); }
MpfrFloat& MpfrFloat::operator%=(const MpfrFloat& rhs) { copyIfShared(); mpfr_fmod(mData->mFloat, mData->mFloat, rhs.mData->mFloat, GMP_RNDN); return *this; }
MpfrFloat& MpfrFloat::operator/=(double value) { copyIfShared(); mpfr_div_d(mData->mFloat, mData->mFloat, value, GMP_RNDN); return *this; }
GmpInt& GmpInt::operator<<=(unsigned long bits) { copyIfShared(); mpz_mul_2exp(mData->mInteger, mData->mInteger, bits); return *this; }
GmpInt& GmpInt::operator/=(const GmpInt& rhs) { copyIfShared(); mpz_tdiv_q(mData->mInteger, mData->mInteger, rhs.mData->mInteger); return *this; }
GmpInt& GmpInt::operator*=(long value) { copyIfShared(); mpz_mul_si(mData->mInteger, mData->mInteger, value); return *this; }