- void divide(const BigInteger &a, const BigInteger &b) {
- // Division, deprecated and provided for compatibility
- BigInteger a2(a);
- a2.divideWithRemainder(b, *this);
- // quotient now in *this
- // don't care about remainder left in a2
- }
- void modulo(const BigInteger &a, const BigInteger &b) {
- // Modular reduction, deprecated and provided for compatibility
- *this = a;
- BigInteger q;
- divideWithRemainder(b, q);
- // remainder now in *this
- // don't care about quotient left in q
- }
- void negate(const BigInteger &a); // Negative
- // Some operations are inherently unsigned and are not
- // redefined for BigIntegers. Calling one of these on
- // a BigInteger will convert it to a BigUnsigned,
- // which takes its absolute value.
-
- // NORMAL OPERATORS
- // These perform the operation on this (to the left of the operator)
- // and x (to the right of the operator) and return a new BigInteger with the result.
- public:
- BigInteger operator +(const BigInteger &x) const; // Addition
- BigInteger operator -(const BigInteger &x) const; // Subtraction
- BigInteger operator *(const BigInteger &x) const; // Multiplication
- BigInteger operator /(const BigInteger &x) const; // Division
- BigInteger operator %(const BigInteger &x) const; // Modular reduction
- BigInteger operator -( ) const; // Negative
-
- // ASSIGNMENT OPERATORS
- // These perform the operation on this and x, storing the result into this.
- public:
- void operator +=(const BigInteger &x); // Addition
- void operator -=(const BigInteger &x); // Subtraction
- void operator *=(const BigInteger &x); // Multiplication
- void operator /=(const BigInteger &x); // Division
- void operator %=(const BigInteger &x); // Modular reduction
- void flipSign(); // Negative