Changeset 31748 in project
 Timestamp:
 11/02/14 14:25:36 (5 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

release/4/numbers/trunk/numbersc.c
r31747 r31748 3424 3424 *q = big_q == C_SCHEME_UNDEFINED ? NULL : C_bignum_digits(big_q), 3425 3425 p, /* product of two halfdigits */ 3426 hat, qhat, rhat; /* estimated quotient and remainder digit */ 3426 hat, qhat, rhat, /* estimated quotient and remainder digit */ 3427 vn_1, vn_2; /* "cached" values v[n1], v[n2] */ 3427 3428 C_word s, i, j, t, k; /* loop and other vars */ 3428 3429 … … 3447 3448 if (HALF_DIGIT_AT(v, n1) == 0) n; 3448 3449 3450 /* These won't change during the loop, but are used in every step. */ 3451 vn_1 = HALF_DIGIT_AT(v, n1); 3452 vn_2 = HALF_DIGIT_AT(v, n2); 3453 3449 3454 /* See also Hacker's Delight, Figure 91. This is almost exactly that. */ 3450 3455 for (j = m  n; j >= 0; j) { 3451 3456 hat = C_BIGNUM_DIGIT_COMBINE(HALF_DIGIT_AT(u,j+n), HALF_DIGIT_AT(u,j+n1)); 3452 qhat = hat / HALF_DIGIT_AT(v, n1);3453 rhat = hat  qhat * HALF_DIGIT_AT(v, n1); /* rhat = hat % v[n1] */3457 qhat = hat / vn_1; 3458 rhat = hat % vn_1; 3454 3459 3455 3460 again: 3456 3461 if (C_BIGNUM_DIGIT_HI_HALF(qhat) > 0  3457 qhat * HALF_DIGIT_AT(v, n2)> C_BIGNUM_DIGIT_COMBINE(rhat, HALF_DIGIT_AT(u,j+n2))) {3462 qhat * vn_2 > C_BIGNUM_DIGIT_COMBINE(rhat, HALF_DIGIT_AT(u,j+n2))) { 3458 3463 qhat; 3459 rhat += HALF_DIGIT_AT(v, n1);3464 rhat += vn_1; 3460 3465 if (C_BIGNUM_DIGIT_HI_HALF(rhat) == 0) goto again; 3461 3466 } … … 3464 3469 k = 0; 3465 3470 for (i = 0; i < n; i++) { 3466 p = qhat * HALF_DIGIT_AT(v, i);3471 p = qhat * HALF_DIGIT_AT(v, i); 3467 3472 t = HALF_DIGIT_AT(u,i+j)  k  (p & C_BIGNUM_HALF_DIGIT_MASK); 3468 3473 STORE_HALF_DIGIT_AT(u, i+j, t); … … 3472 3477 STORE_HALF_DIGIT_AT(u, j+n, t); 3473 3478 3474 if (q != NULL) {3475 STORE_HALF_DIGIT_AT(q, j, qhat);3476 }3477 3478 3479 if (t < 0) { /* Subtracted too much? */ 3479 if (q != NULL) { 3480 STORE_HALF_DIGIT_AT(q, j, HALF_DIGIT_AT(q, j)  1); /* Add back */ 3481 } 3480 qhat; 3482 3481 k = 0; 3483 3482 for (i = 0; i < n; i++) { … … 3488 3487 STORE_HALF_DIGIT_AT(u, j+n, (HALF_DIGIT_AT(u, j+n) + k)); 3489 3488 } 3489 if (q != NULL) STORE_HALF_DIGIT_AT(q, j, qhat); 3490 3490 } /* end j */ 3491 3491 }
Note: See TracChangeset
for help on using the changeset viewer.