- void divide (const BigInteger &a, const BigInteger &b); // Division
- void modulo (const BigInteger &a, const BigInteger &b); // Modular reduction
- void negate (const BigInteger &a ); // Negative
+ /* Divisive stuff
+ * `a.divideWithRemainder(b, q)' is like `q = a / b, a %= b'.
+ * Semantics similar to Donald E. Knuth's are used for / and %,
+ * and these usually differ from the semantics of primitive-type
+ * / and % when negatives and/or zeroes are involved.
+ * Look in `BigInteger.cc' for details.
+ */
+ void divideWithRemainder(const BigInteger &b, BigInteger &q);
+ 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