diff -r dd51c4da0cc8 BigInteger.cc
--- a/BigInteger.cc	Mon Dec 05 22:47:34 2011 +0100
+++ b/BigInteger.cc	Tue Dec 06 00:30:13 2011 +0100
@@ -1,13 +1,14 @@
 #include "BigInteger.hh"
 
-void BigInteger::operator =(const BigInteger &x) {
+BigInteger& BigInteger::operator =(const BigInteger &x) {
 	// Calls like a = a have no effect
 	if (this == &x)
-		return;
+		return *this;
 	// Copy sign
 	sign = x.sign;
 	// Copy the rest
 	mag = x.mag;
+	return *this;
 }
 
 BigInteger::BigInteger(const Blk *b, Index blen, Sign s) : mag(b, blen) {
@@ -370,7 +371,7 @@
 // INCREMENT/DECREMENT OPERATORS
 
 // Prefix increment
-void BigInteger::operator ++() {
+BigInteger& BigInteger::operator ++() {
 	if (sign == negative) {
 		mag--;
 		if (mag == 0)
@@ -379,15 +380,18 @@
 		mag++;
 		sign = positive; // if not already
 	}
+	return *this;
 }
 
 // Postfix increment: same as prefix
-void BigInteger::operator ++(int) {
-	operator ++();
+BigInteger BigInteger::operator ++(int) {
+	BigInteger result = *this;
+	++*this;
+	return result;
 }
 
 // Prefix decrement
-void BigInteger::operator --() {
+BigInteger& BigInteger::operator --() {
 	if (sign == positive) {
 		mag--;
 		if (mag == 0)
@@ -396,10 +400,13 @@
 		mag++;
 		sign = negative;
 	}
+	return *this;
 }
 
 // Postfix decrement: same as prefix
-void BigInteger::operator --(int) {
-	operator --();
+BigInteger BigInteger::operator --(int) {
+	BigInteger result = *this;
+	--*this;
+	return result;
 }
 
diff -r dd51c4da0cc8 BigInteger.hh
--- a/BigInteger.hh	Mon Dec 05 22:47:34 2011 +0100
+++ b/BigInteger.hh	Tue Dec 06 00:30:13 2011 +0100
@@ -35,7 +35,7 @@
 	BigInteger(const BigInteger &x) : sign(x.sign), mag(x.mag) {};
 
 	// Assignment operator
-	void operator=(const BigInteger &x);
+	BigInteger& operator=(const BigInteger &x);
 
 	// Constructor that copies from a given array of blocks with a sign.
 	BigInteger(const Blk *b, Index blen, Sign s);
@@ -123,18 +123,18 @@
 	BigInteger operator %(const BigInteger &x) const;
 	BigInteger operator -() const;
 
-	void operator +=(const BigInteger &x);
-	void operator -=(const BigInteger &x);
-	void operator *=(const BigInteger &x);
-	void operator /=(const BigInteger &x);
-	void operator %=(const BigInteger &x);
+	BigInteger& operator +=(const BigInteger &x);
+	BigInteger& operator -=(const BigInteger &x);
+	BigInteger& operator *=(const BigInteger &x);
+	BigInteger& operator /=(const BigInteger &x);
+	BigInteger& operator %=(const BigInteger &x);
 	void flipSign();
 
 	// INCREMENT/DECREMENT OPERATORS
-	void operator ++(   );
-	void operator ++(int);
-	void operator --(   );
-	void operator --(int);
+	BigInteger& operator ++(   );
+	BigInteger  operator ++(int);
+	BigInteger& operator --(   );
+	BigInteger  operator --(int);
 };
 
 // NORMAL OPERATORS
@@ -183,16 +183,19 @@
  * belongs to the put-here operations.  See Assignment Operators in
  * BigUnsigned.hh.
  */
-inline void BigInteger::operator +=(const BigInteger &x) {
+inline BigInteger& BigInteger::operator +=(const BigInteger &x) {
 	add(*this, x);
+	return *this;
 }
-inline void BigInteger::operator -=(const BigInteger &x) {
+inline BigInteger& BigInteger::operator -=(const BigInteger &x) {
 	subtract(*this, x);
+	return *this;
 }
-inline void BigInteger::operator *=(const BigInteger &x) {
+inline BigInteger& BigInteger::operator *=(const BigInteger &x) {
 	multiply(*this, x);
+	return *this;
 }
-inline void BigInteger::operator /=(const BigInteger &x) {
+inline BigInteger& BigInteger::operator /=(const BigInteger &x) {
 	if (x.isZero()) throw "BigInteger::operator /=: division by zero";
 	/* The following technique is slightly faster than copying *this first
 	 * when x is large. */
@@ -200,12 +203,14 @@
 	divideWithRemainder(x, q);
 	// *this contains the remainder, but we overwrite it with the quotient.
 	*this = q;
+	return *this;
 }
-inline void BigInteger::operator %=(const BigInteger &x) {
+inline BigInteger& BigInteger::operator %=(const BigInteger &x) {
 	if (x.isZero()) throw "BigInteger::operator %=: division by zero";
 	BigInteger q;
 	// Mods *this by x.  Don't care about quotient left in q.
 	divideWithRemainder(x, q);
+	return *this;
 }
 // This one is trivial
 inline void BigInteger::flipSign() {
diff -r dd51c4da0cc8 BigIntegerUtils.cc
--- a/BigIntegerUtils.cc	Mon Dec 05 22:47:34 2011 +0100
+++ b/BigIntegerUtils.cc	Tue Dec 06 00:30:13 2011 +0100
@@ -22,7 +22,7 @@
 		: BigInteger(stringToBigUnsigned(s));
 }
 
-std::ostream &operator <<(std::ostream &os, const BigUnsigned &x) {
+void writeBigUnsignedToStream(std::ostream&os, const BigUnsigned &x, const std::string& sign) {
 	BigUnsignedInABase::Base base;
 	long osFlags = os.flags();
 	if (osFlags & os.dec)
@@ -37,14 +37,24 @@
 			os << '0';
 	} else
 		throw "std::ostream << BigUnsigned: Could not determine the desired base from output-stream flags";
-	std::string s = std::string(BigUnsignedInABase(x, base));
+	std::string s = sign + std::string(BigUnsignedInABase(x, base));
 	os << s;
+}
+
+std::ostream &operator <<(std::ostream &os, const BigUnsigned &x) {
+	std::string sign;
+	if (os.flags() & std::ios_base::showpos)
+		sign = '+';
+	writeBigUnsignedToStream(os, x, sign);
 	return os;
 }
 
 std::ostream &operator <<(std::ostream &os, const BigInteger &x) {
+	std::string sign;
 	if (x.getSign() == BigInteger::negative)
-		os << '-';
-	os << x.getMagnitude();
+		sign = '-';
+	else if (os.flags() & std::ios_base::showpos)
+		sign = '+';
+	writeBigUnsignedToStream(os, x.getMagnitude(), sign);
 	return os;
 }
diff -r dd51c4da0cc8 BigUnsigned.cc
--- a/BigUnsigned.cc	Mon Dec 05 22:47:34 2011 +0100
+++ b/BigUnsigned.cc	Tue Dec 06 00:30:13 2011 +0100
@@ -656,7 +656,7 @@
 // INCREMENT/DECREMENT OPERATORS
 
 // Prefix increment
-void BigUnsigned::operator ++() {
+BigUnsigned& BigUnsigned::operator ++() {
 	Index i;
 	bool carry = true;
 	for (i = 0; i < len && carry; i++) {
@@ -669,15 +669,18 @@
 		len++;
 		blk[i] = 1;
 	}
+	return *this;
 }
 
 // Postfix increment: same as prefix
-void BigUnsigned::operator ++(int) {
-	operator ++();
+BigUnsigned BigUnsigned::operator ++(int) {
+	BigUnsigned result = *this;
+	++*this;
+	return result;
 }
 
 // Prefix decrement
-void BigUnsigned::operator --() {
+BigUnsigned& BigUnsigned::operator --() {
 	if (len == 0)
 		throw "BigUnsigned::operator --(): Cannot decrement an unsigned zero";
 	Index i;
@@ -689,9 +692,12 @@
 	// Zap possible leading zero (there can only be one)
 	if (blk[len - 1] == 0)
 		len--;
+	return *this;
 }
 
 // Postfix decrement: same as prefix
-void BigUnsigned::operator --(int) {
-	operator --();
+BigUnsigned BigUnsigned::operator --(int) {
+	BigUnsigned result = *this;
+	--*this;
+	return result;
 }
diff -r dd51c4da0cc8 BigUnsigned.hh
--- a/BigUnsigned.hh	Mon Dec 05 22:47:34 2011 +0100
+++ b/BigUnsigned.hh	Tue Dec 06 00:30:13 2011 +0100
@@ -40,8 +40,9 @@
 	BigUnsigned(const BigUnsigned &x) : NumberlikeArray<Blk>(x) {}
 
 	// Assignment operator
-	void operator=(const BigUnsigned &x) {
+	BigUnsigned& operator=(const BigUnsigned &x) {
 		NumberlikeArray<Blk>::operator =(x);
+		return *this;
 	}
 
 	// Constructor that copies from a given array of blocks.
@@ -212,24 +213,24 @@
 	BigUnsigned operator >>(int b) const;
 
 	// OVERLOADED ASSIGNMENT OPERATORS
-	void operator +=(const BigUnsigned &x);
-	void operator -=(const BigUnsigned &x);
-	void operator *=(const BigUnsigned &x);
-	void operator /=(const BigUnsigned &x);
-	void operator %=(const BigUnsigned &x);
-	void operator &=(const BigUnsigned &x);
-	void operator |=(const BigUnsigned &x);
-	void operator ^=(const BigUnsigned &x);
-	void operator <<=(int b);
-	void operator >>=(int b);
+	BigUnsigned& operator +=(const BigUnsigned &x);
+	BigUnsigned& operator -=(const BigUnsigned &x);
+	BigUnsigned& operator *=(const BigUnsigned &x);
+	BigUnsigned& operator /=(const BigUnsigned &x);
+	BigUnsigned& operator %=(const BigUnsigned &x);
+	BigUnsigned& operator &=(const BigUnsigned &x);
+	BigUnsigned& operator |=(const BigUnsigned &x);
+	BigUnsigned& operator ^=(const BigUnsigned &x);
+	BigUnsigned& operator <<=(int b);
+	BigUnsigned& operator >>=(int b);
 
 	/* INCREMENT/DECREMENT OPERATORS
 	 * To discourage messy coding, these do not return *this, so prefix
 	 * and postfix behave the same. */
-	void operator ++(   );
-	void operator ++(int);
-	void operator --(   );
-	void operator --(int);
+	BigUnsigned& operator ++(   );
+	BigUnsigned  operator ++(int);
+	BigUnsigned& operator --(   );
+	BigUnsigned  operator --(int);
 
 	// Helper function that needs access to BigUnsigned internals
 	friend Blk getShiftedBlock(const BigUnsigned &num, Index x,
@@ -299,16 +300,19 @@
 	return ans;
 }
 
-inline void BigUnsigned::operator +=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator +=(const BigUnsigned &x) {
 	add(*this, x);
+	return *this;
 }
-inline void BigUnsigned::operator -=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator -=(const BigUnsigned &x) {
 	subtract(*this, x);
+	return *this;
 }
-inline void BigUnsigned::operator *=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator *=(const BigUnsigned &x) {
 	multiply(*this, x);
+	return *this;
 }
-inline void BigUnsigned::operator /=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator /=(const BigUnsigned &x) {
 	if (x.isZero()) throw "BigUnsigned::operator /=: division by zero";
 	/* The following technique is slightly faster than copying *this first
 	 * when x is large. */
@@ -316,27 +320,34 @@
 	divideWithRemainder(x, q);
 	// *this contains the remainder, but we overwrite it with the quotient.
 	*this = q;
+	return *this;
 }
-inline void BigUnsigned::operator %=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator %=(const BigUnsigned &x) {
 	if (x.isZero()) throw "BigUnsigned::operator %=: division by zero";
 	BigUnsigned q;
 	// Mods *this by x.  Don't care about quotient left in q.
 	divideWithRemainder(x, q);
+	return *this;
 }
-inline void BigUnsigned::operator &=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator &=(const BigUnsigned &x) {
 	bitAnd(*this, x);
+	return *this;
 }
-inline void BigUnsigned::operator |=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator |=(const BigUnsigned &x) {
 	bitOr(*this, x);
+	return *this;
 }
-inline void BigUnsigned::operator ^=(const BigUnsigned &x) {
+inline BigUnsigned& BigUnsigned::operator ^=(const BigUnsigned &x) {
 	bitXor(*this, x);
+	return *this;
 }
-inline void BigUnsigned::operator <<=(int b) {
+inline BigUnsigned& BigUnsigned::operator <<=(int b) {
 	bitShiftLeft(*this, b);
+	return *this;
 }
-inline void BigUnsigned::operator >>=(int b) {
+inline BigUnsigned& BigUnsigned::operator >>=(int b) {
 	bitShiftRight(*this, b);
+	return *this;
 }
 
 /* Templates for conversions of BigUnsigned to and from primitive integers.
