- Add some big-integer algorithms.
[bigint/bigint.git] / BigUnsignedInABase.cc
index b423ca2..41bbfba 100644 (file)
@@ -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++;
        }