- void divide(const BigUnsigned &a, const BigUnsigned &b) {
- BigUnsigned a2(a);
- a2.divideWithRemainder(b, *this);
- // quotient now in *this
- // don't care about remainder left in a2
- }
- void modulo(const BigUnsigned &a, const BigUnsigned &b) {
- *this = a;
- BigUnsigned q;
- divideWithRemainder(b, q);
- // remainder now in *this
- // don't care about quotient left in q
- }
- // Bitwise operations. Result left in *this.
- // These are not provided for BigIntegers; I think that using them on BigIntegers
- // will discard the sign first.
- void bitAnd(const BigUnsigned &a, const BigUnsigned &b); // Bitwise AND
- void bitOr(const BigUnsigned &a, const BigUnsigned &b); // Bitwise OR
- void bitXor(const BigUnsigned &a, const BigUnsigned &b); // Bitwise XOR
- void bitShiftLeft(const BigUnsigned &a, unsigned int b); // Bitwise left shift
- void bitShiftRight(const BigUnsigned &a, unsigned int b); // Bitwise right shift
-
- // 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 BigUnsigned with the result.
-public:
- BigUnsigned operator +(const BigUnsigned &x) const; // Addition
- BigUnsigned operator -(const BigUnsigned &x) const; // Subtraction
- BigUnsigned operator *(const BigUnsigned &x) const; // Multiplication
- BigUnsigned operator /(const BigUnsigned &x) const; // Division
- BigUnsigned operator %(const BigUnsigned &x) const; // Modular reduction
- BigUnsigned operator &(const BigUnsigned &x) const; // Bitwise AND
- BigUnsigned operator |(const BigUnsigned &x) const; // Bitwise OR
- BigUnsigned operator ^(const BigUnsigned &x) const; // Bitwise XOR
- BigUnsigned operator <<(unsigned int b) const; // Bitwise left shift
- BigUnsigned operator >>(unsigned int b) const; // Bitwise right shift
- // Additional operators in an attempt to avoid overloading tangles.
+
+ /* `divide' and `modulo' are no longer offered. Use
+ * `divideWithRemainder' instead. */
+
+ // OVERLOADED RETURN-BY-VALUE OPERATORS
+ BigUnsigned operator +(const BigUnsigned &x) const;
+ BigUnsigned operator -(const BigUnsigned &x) const;
+ BigUnsigned operator *(const BigUnsigned &x) const;
+ BigUnsigned operator /(const BigUnsigned &x) const;
+ BigUnsigned operator %(const BigUnsigned &x) const;
+ /* OK, maybe unary minus could succeed in one case, but it really
+ * shouldn't be used, so it isn't provided. */
+ BigUnsigned operator &(const BigUnsigned &x) const;
+ BigUnsigned operator |(const BigUnsigned &x) const;
+ BigUnsigned operator ^(const BigUnsigned &x) const;