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
I decided to delete whitespace from otherwise empty lines.
[bigint/bigint.git]
/
BigInteger.cc
diff --git
a/BigInteger.cc
b/BigInteger.cc
index
ba49180
..
3873e15
100644
(file)
--- a/
BigInteger.cc
+++ b/
BigInteger.cc
@@
-443,7
+443,7
@@
void BigInteger::divideWithRemainder(const BigInteger &b, BigInteger &q) {
divideWithRemainder(tmpB, q);
return;
}
divideWithRemainder(tmpB, q);
return;
}
-
+
// Division by zero gives quotient 0 and remainder *this
if (b.sign == zero) {
q.len = 0;
// Division by zero gives quotient 0 and remainder *this
if (b.sign == zero) {
q.len = 0;
@@
-456,9
+456,9
@@
void BigInteger::divideWithRemainder(const BigInteger &b, BigInteger &q) {
q.sign = zero;
return;
}
q.sign = zero;
return;
}
-
+
// Here *this != 0, b != 0.
// Here *this != 0, b != 0.
-
+
// Do the operands have the same sign?
if (sign == b.sign) {
// Yes: easy case. Quotient is zero or positive.
// Do the operands have the same sign?
if (sign == b.sign) {
// Yes: easy case. Quotient is zero or positive.
@@
-489,10
+489,10
@@
void BigInteger::divideWithRemainder(const BigInteger &b, BigInteger &q) {
* Find r = (b - 1) - R and give it the desired sign.
*/
}
* Find r = (b - 1) - R and give it the desired sign.
*/
}
-
+
// Divide the magnitudes.
BigUnsigned::divideWithRemainder(b, q);
// Divide the magnitudes.
BigUnsigned::divideWithRemainder(b, q);
-
+
if (sign != b.sign) {
// More for the harder case (as described):
// Increase the magnitude of the quotient by one.
if (sign != b.sign) {
// More for the harder case (as described):
// Increase the magnitude of the quotient by one.
@@
-502,16
+502,16
@@
void BigInteger::divideWithRemainder(const BigInteger &b, BigInteger &q) {
BigUnsigned::subtract(b, temp);
BigUnsigned::operator --();
}
BigUnsigned::subtract(b, temp);
BigUnsigned::operator --();
}
-
+
// Sign of the remainder is always the sign of the divisor b.
sign = b.sign;
// Sign of the remainder is always the sign of the divisor b.
sign = b.sign;
-
+
// Set signs to zero as necessary. (Thanks David Allen!)
if (len == 0)
sign = zero;
if (q.len == 0)
q.sign = zero;
// Set signs to zero as necessary. (Thanks David Allen!)
if (len == 0)
sign = zero;
if (q.len == 0)
q.sign = zero;
-
+
// WHEW!!!
}
// WHEW!!!
}