Matt McCutchen's Web Site
/
bigint
/
bigint.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Old snapshot `bigint-2006.02.26'; see the ChangeLog file.
[bigint/bigint.git]
/
BigInteger.cc
diff --git
a/BigInteger.cc
b/BigInteger.cc
index
69d2dd7
..
0ad7fc1
100644
(file)
--- a/
BigInteger.cc
+++ b/
BigInteger.cc
@@
-1,6
+1,6
@@
/*
* Matt McCutchen's Big Integer Library
/*
* Matt McCutchen's Big Integer Library
-* http://
mysite.verizon.net/mccutchen
/bigint/
+* http://
hashproduct.metaesthetics.net
/bigint/
*/
#include "BigInteger.hh"
*/
#include "BigInteger.hh"
@@
-358,9
+358,11
@@
void BigInteger::subtract(const BigInteger &a, const BigInteger &b) {
// If a is zero, copy b and flip its sign. If b is zero, copy a.
if (a.sign == zero) {
BigUnsigned::operator =(b);
// If a is zero, copy b and flip its sign. If b is zero, copy a.
if (a.sign == zero) {
BigUnsigned::operator =(b);
- sign = Sign(-sign);
+ // Take the negative of _b_'s, sign, not ours.
+ // Bug pointed out by Sam Larkin on 2005.03.30.
+ sign = Sign(-b.sign);
} else if (b.sign == zero)
} else if (b.sign == zero)
- operator =(a);
+
operator =(a);
// If their signs differ, take a.sign and add the magnitudes.
else if (a.sign != b.sign) {
sign = a.sign;
// If their signs differ, take a.sign and add the magnitudes.
else if (a.sign != b.sign) {
sign = a.sign;