t j = m;
   do {
      //DEBUG(cerr << "KnuthDiv: quotient digit #" << j << '\n');
      // D3. [Calculate q'.].
      //     Set qp = (u[j+n]*b + u[j+n-1]) / v[n-1]. (qp=qprime=q')
      //     Set rp = (u[j+n]*b + u[j+n-1]) % v[n-1]. (rp=rprime=r')
      // Now test if qp == b or qp*v[n-2] > b*rp + u[j+n-2]; if so, decrease
      // qp by 1, inrease rp by v[n-1], and repeat this test if rp < b.
      // The test on v[n-2] determines at high speed most of the cases in
      // which the trial value qp is one too large, and it eliminates all
      // cases where qp is two too large.
      uint64_t dividend = ((uint64_t(u[j+n]) << 32) + u[j+n-1]);
      //DEBUG(cerr << "KnuthDiv: dividend == " << dividend << '\n');
      uint64_t qp = dividend / v[n-1];
      uint64_t rp = dividend % v[n-1];
      if (qp == b || qp*v[n-2] > b*rp + u[j+n-2]) {
         qp--;
         rp += v[n-1];
         if (rp < b && (qp == b || qp*v[n-2] > b*rp + u[j+n-2])) {
            qp--;
         }
      }
      // D4. [Multiply and subtract.] Replace (u[j+n]u[j+n-1]...u[j]) with
      // (u[j+n]u[j+n-1]..u[j]) - qp * (v[n-1]...v[1]v[0]). This computation
      // consists of a simple multiplication by a one-place number,
      // combined with a subtraction.
      bool isNeg = false;
      for (uint16_t i = 0; i < n; ++i) {
         uint64_t u_tmp = uint64_t(u[j+i]) | ((uint64_t(u[j+i+1])) << 32);
         uint64_t subtrahend = uint64_t(qp) * uint64_t(v[i]);
         bool borrow = subtrahend > u_tmp;

         uint64_t result = u_tmp - subtrahend;
         uint16_t k = j + i;
         u[k++] = (uint32_t)(result & (b-1)); // subtract low word
         u[k++] = (uint32_t)((result) >> 32); // subtract high word
         while (borrow && k <= m+n) {         // deal with borrow to the left
            borrow = u[k] == 0;
            u[k]--;
            k++;
         }
         isNeg |= borrow;
      }
      // The digits (u[j+n]...u[j]) should be kept positive; if the result of
      // this step is