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.05.01'; see the ChangeLog file.
[bigint/bigint.git]
/
BigUnsigned.cc
diff --git
a/BigUnsigned.cc
b/BigUnsigned.cc
index
4074822
..
33fe0af
100644
(file)
--- a/
BigUnsigned.cc
+++ b/
BigUnsigned.cc
@@
-1,6
+1,5
@@
/*
* Matt McCutchen's Big Integer Library
/*
* Matt McCutchen's Big Integer Library
-* http://mysite.verizon.net/mccutchen/bigint/
*/
#include "BigUnsigned.hh"
*/
#include "BigUnsigned.hh"
@@
-428,7
+427,7
@@
void BigUnsigned::multiply(const BigUnsigned &a, const BigUnsigned &b) {
for (i = 0; i < a.len; i++) {
// For each 1-bit of that block...
for (i2 = 0; i2 < N; i2++) {
for (i = 0; i < a.len; i++) {
// For each 1-bit of that block...
for (i2 = 0; i2 < N; i2++) {
- if ((a.blk[i] & (
1
<< i2)) == 0)
+ if ((a.blk[i] & (
Blk(1)
<< i2)) == 0)
continue;
/*
* Add b to this, shifted left i blocks and i2 bits.
continue;
/*
* Add b to this, shifted left i blocks and i2 bits.
@@
-623,7
+622,7
@@
void BigUnsigned::divideWithRemainder(const BigUnsigned &b, BigUnsigned &q) {
* the region of work2 we copy is just [i, k).
*/
if (!borrowIn) {
* the region of work2 we copy is just [i, k).
*/
if (!borrowIn) {
- q.blk[i] |= (
1
<< i2);
+ q.blk[i] |= (
Blk(1)
<< i2);
while (k > i) {
k--;
blk[k] = work2[k];
while (k > i) {
k--;
blk[k] = work2[k];
@@
-752,8
+751,10
@@
void BigUnsigned::operator ++() {
}
if (carry) {
// Matt fixed a bug 2004.12.24: next 2 lines used to say allocateAndCopy(len + 1)
}
if (carry) {
// Matt fixed a bug 2004.12.24: next 2 lines used to say allocateAndCopy(len + 1)
+ // Matt fixed another bug 2006.04.24:
+ // old number only has len blocks, so copy before increasing length
+ allocateAndCopy(len + 1);
len++;
len++;
- allocateAndCopy(len);
blk[i] = 1;
}
}
blk[i] = 1;
}
}