vn[0] = v[0] << s;
}
+long bigdiv(unsigned v, unsigned q[], unsigned const u[], int m)
+{
+ long long k = 0; // the case of a
+ for (int j = m - 1; j >= 0; j--) { // single-digit
+ unsigned long d2 = (k << 32) | u[j];
+ q[j] = d2 / v; // divisor here.
+ k = d2 % v;
+ }
+ return k;
+}
+
bool bigmul(unsigned long long qhat, unsigned product[], unsigned vn[], int m,
int n)
{
return 1; // Return if invalid param.
if (n == 1) { // Take care of
- k = 0; // the case of a
- for (j = m - 1; j >= 0; j--) { // single-digit
- q[j] = (k * b + u[j]) / v[0]; // divisor here.
- k = (k * b + u[j]) - q[j] * v[0];
- }
+ k = bigdiv(v[0], q, u, m);
if (r != NULL)
r[0] = k;
return 0;