X-Git-Url: https://mattmccutchen.net/bigint/bigint.git/blobdiff_plain/5ff40cf5d6e822051da902b041ae7ae8f545123e..7f07d1d6bfa8629106c93c1d9641d2713460ac84:/BigUnsignedInABase.cc diff --git a/BigUnsignedInABase.cc b/BigUnsignedInABase.cc index b423ca2..41bbfba 100644 --- a/BigUnsignedInABase.cc +++ b/BigUnsignedInABase.cc @@ -1,15 +1,11 @@ /* -* Matt McCutchen's Big Integer Library -*/ - -/* -* Milan Tomic had trouble compiling this file on Microsoft -* Visual C++ 6 because, in the libraries that come with -* Visual C++ 6, the `std::string::push_back' method apparently -* does not exist. To get around the problem, I rewrote -* `BigUnsignedInABase::operator std::string' (at the bottom -* of this file) so it doesn't use `push_back'. -*/ + * Milan Tomic had trouble compiling this file on Microsoft + * Visual C++ 6 because, in the libraries that come with + * Visual C++ 6, the `std::string::push_back' method apparently + * does not exist. To get around the problem, I rewrote + * `BigUnsignedInABase::operator std::string' (at the bottom + * of this file) so it doesn't use `push_back'. + */ #include "BigUnsignedInABase.hh" @@ -40,7 +36,7 @@ BigUnsignedInABase::BigUnsignedInABase(const BigUnsigned &x, Base base) { int maxBitLenOfX = x.getLength() * BigUnsigned::N; int minBitsPerDigit = bitLen(base) - 1; int maxDigitLenOfX = ceilingDiv(maxBitLenOfX, minBitsPerDigit); - len = maxDigitLenOfX; // Another change to comply with `staying in bounds'; see `BigUnsigned::divideWithRemainder'. + len = maxDigitLenOfX; // Another change to comply with `staying in bounds'. allocate(len); // Get the space BigUnsigned x2(x), buBase(base); @@ -51,7 +47,7 @@ BigUnsignedInABase::BigUnsignedInABase(const BigUnsigned &x, Base base) { BigUnsigned lastDigit(x2); lastDigit.divideWithRemainder(buBase, x2); // Save the digit. - blk[digitNum] = Digit(lastDigit); // invokes `BigUnsigned ==> unsigned short' converter + blk[digitNum] = lastDigit.toUnsignedShort(); // Move on. We can't run out of room: we figured it out above. digitNum++; }