un[i+j] = (t & 0xffffffffLL);
k = (p >> 32) - (t >> 32);
}
+ t = un[j+n] - k;
+ un[j+n] = t;
#endif
+#define EXPERIMENT1
+ k = 1;
#ifdef EXPERIMENT1
- for (i = 0; i < n; i++) {
+ for (i = 0; i < n+1; i++) {
unsigned rhi;
unsigned long long sum;
- p = ((unsigned long long)un[i+j])+ ~(qhat*vn[i]) + k;
- rhi = (p >> 32);
+ if (i != n) {
+ p = qhat*vn[i];
+ sum = ((unsigned long long)un[i+j]) + ~p + k;
+ } else { // for last loop instead of separate cleanup do special sum
+ sum = (~0)+k;
+ }
+ rhi = (sum >> 32);
if (((unsigned long long)k) <= 1) rhi += 1;
k = rhi;
un[i+j] = sum & 0xffffffff;
}
+ // XXX t is not properly computed, it must contain -ve
+ // if the subtract should not have occurred
#endif
-#define EXPERIMENT2
+//#define EXPERIMENT2
#ifdef EXPERIMENT2
+ k = 0;
unsigned long phi[200]; // yes, not malloced, we know
unsigned long plo[200]; // yes, not malloced, we know
// double-width multiply with strange subtract only on bottom half
un[i+j] = (t & 0xffffffffLL);
k = phi[i] - (t >> 32); // take top-halves for new carry
}
-#endif
t = un[j+n] - k;
un[j+n] = t;
+#endif
q[j] = qhat; // Store quotient digit.
if (t < 0) { // If we subtracted too