// MANAGEMENT
protected:
BigInteger(Sign s, Index c) : BigUnsigned(0, c), sign(s) {}; // Creates a BigInteger with a sign and capacity
// MANAGEMENT
protected:
BigInteger(Sign s, Index c) : BigUnsigned(0, c), sign(s) {}; // Creates a BigInteger with a sign and capacity
BigInteger( short x);
// Note that a BigInteger can be converted to a BigUnsigned
// automatically; this takes its absolute value.
BigInteger( short x);
// Note that a BigInteger can be converted to a BigUnsigned
// automatically; this takes its absolute value.
bool operator <=(const BigInteger &x) const { return compareTo(x) != greater; }
bool operator >=(const BigInteger &x) const { return compareTo(x) != less ; }
bool operator > (const BigInteger &x) const { return compareTo(x) == greater; }
bool operator <=(const BigInteger &x) const { return compareTo(x) != greater; }
bool operator >=(const BigInteger &x) const { return compareTo(x) != less ; }
bool operator > (const BigInteger &x) const { return compareTo(x) == greater; }
// PUT-HERE OPERATIONS
/* These store the result of the operation on the arguments into this.
* a.add(b, c) is equivalent to, but faster than, a = b + c.
// PUT-HERE OPERATIONS
/* These store the result of the operation on the arguments into this.
* a.add(b, c) is equivalent to, but faster than, a = b + c.
public:
void add (const BigInteger &a, const BigInteger &b); // Addition
void subtract(const BigInteger &a, const BigInteger &b); // Subtraction
public:
void add (const BigInteger &a, const BigInteger &b); // Addition
void subtract(const BigInteger &a, const BigInteger &b); // Subtraction
* and these usually differ from the semantics of primitive-type
* / and % when negatives and/or zeroes are involved.
* Look in `BigInteger.cc' for details.
* 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) {
*/
void divideWithRemainder(const BigInteger &b, BigInteger &q);
void divide(const BigInteger &a, const BigInteger &b) {
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) {
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) {
// redefined for BigIntegers. Calling one of these on
// a BigInteger will convert it to a BigUnsigned,
// which takes its absolute value.
// 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.
// 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.
BigInteger operator /(const BigInteger &x) const; // Division
BigInteger operator %(const BigInteger &x) const; // Modular reduction
BigInteger operator -( ) const; // Negative
BigInteger operator /(const BigInteger &x) const; // Division
BigInteger operator %(const BigInteger &x) const; // Modular reduction
BigInteger operator -( ) const; // Negative
void operator /=(const BigInteger &x); // Division
void operator %=(const BigInteger &x); // Modular reduction
void flipSign(); // Negative
void operator /=(const BigInteger &x); // Division
void operator %=(const BigInteger &x); // Modular reduction
void flipSign(); // Negative
// INCREMENT/DECREMENT OPERATORS
// These increase or decrease the number by 1. To discourage side effects,
// these do not return *this, so prefix and postfix behave the same.
// INCREMENT/DECREMENT OPERATORS
// These increase or decrease the number by 1. To discourage side effects,
// these do not return *this, so prefix and postfix behave the same.
void operator ++(int); // Postfix decrement
void operator --( ); // Prefix increment
void operator --(int); // Postfix decrement
void operator ++(int); // Postfix decrement
void operator --( ); // Prefix increment
void operator --(int); // Postfix decrement
-// ASSIGNMENT OPERATORS
-// These create a copy of this, then invoke the appropriate
-// put-here operation on this, passing the copy and x.
+/*
+ * ASSIGNMENT OPERATORS
+ *
+ * Now the responsibility for making a temporary copy if necessary
+ * belongs to the put-here operations. See Assignment Operators in
+ * BigUnsigned.hh.
+ */