Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}
Ejemplo n.º 4
0
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;
}
Ejemplo n.º 5
0
void MpfrFloat::abs()
{
    copyIfShared();
    mpfr_abs(mData->mFloat, mData->mFloat, GMP_RNDN);
}
Ejemplo n.º 6
0
//===========================================================================
// Modifying functions
//===========================================================================
void MpfrFloat::negate()
{
    copyIfShared();
    mpfr_neg(mData->mFloat, mData->mFloat, GMP_RNDN);
}
Ejemplo n.º 7
0
MpfrFloat& MpfrFloat::operator%=(const MpfrFloat& rhs)
{
    copyIfShared();
    mpfr_fmod(mData->mFloat, mData->mFloat, rhs.mData->mFloat, GMP_RNDN);
    return *this;
}
Ejemplo n.º 8
0
MpfrFloat& MpfrFloat::operator/=(double value)
{
    copyIfShared();
    mpfr_div_d(mData->mFloat, mData->mFloat, value, GMP_RNDN);
    return *this;
}
Ejemplo n.º 9
0
GmpInt& GmpInt::operator<<=(unsigned long bits)
{
    copyIfShared();
    mpz_mul_2exp(mData->mInteger, mData->mInteger, bits);
    return *this;
}
Ejemplo n.º 10
0
GmpInt& GmpInt::operator/=(const GmpInt& rhs)
{
    copyIfShared();
    mpz_tdiv_q(mData->mInteger, mData->mInteger, rhs.mData->mInteger);
    return *this;
}
Ejemplo n.º 11
0
GmpInt& GmpInt::operator*=(long value)
{
    copyIfShared();
    mpz_mul_si(mData->mInteger, mData->mInteger, value);
    return *this;
}