Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 5 additions & 27 deletions ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6014,7 +6014,7 @@ VpDivd(Real *c, Real *r, Real *a, Real *b)
size_t i, n, ind_a, ind_b, ind_c, ind_r;
size_t nLoop;
DECDIG_DBL q, b1, b1p1, b1b2, b1b2p1, r1r2;
DECDIG borrow, borrow1, borrow2;
DECDIG borrow1, borrow2;
DECDIG_DBL qb;

VpSetNaN(r);
Expand Down Expand Up @@ -6078,26 +6078,11 @@ VpDivd(Real *c, Real *r, Real *a, Real *b)
}
/* The first few word digits of r and b is the same and */
/* the first different word digit of w is greater than that */
/* of b, so quotient is 1 and just subtract b from r. */
borrow = 0; /* quotient=1, then just r-b */
ind_b = b->Prec - 1;
ind_r = ind_c + ind_b;
if (ind_r >= word_r) goto space_error;
n = ind_b;
for (i = 0; i <= n; ++i) {
if (r->frac[ind_r] < b->frac[ind_b] + borrow) {
r->frac[ind_r] += (BASE - (b->frac[ind_b] + borrow));
borrow = 1;
}
else {
r->frac[ind_r] = r->frac[ind_r] - b->frac[ind_b] - borrow;
borrow = 0;
}
--ind_r;
--ind_b;
}
/* of b, so quotient is 1. */
q = 1;
++c->frac[ind_c];
goto carry;
ind_r = b->Prec + ind_c - 1;
goto sub_mult;
}
/* The first two word digits is not the same, */
/* then compare magnitude, and divide actually. */
Expand Down Expand Up @@ -6150,13 +6135,6 @@ VpDivd(Real *c, Real *r, Real *a, Real *b)
}

r->frac[ind_r] -= borrow2;
carry:
ind_r = ind_c;
while (c->frac[ind_r] >= BASE) {
c->frac[ind_r] -= BASE;
--ind_r;
++c->frac[ind_r];
}
}
/* End of operation, now final arrangement */
out_side:
Expand Down
2 changes: 1 addition & 1 deletion test/bigdecimal/test_vp_operation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_vpdivd_precisions
end
end

def test_vpdivd_carry_borrow
def test_vpdivd_borrow
y_small = BASE / 7 * BASE ** 4
y_large = (4 * BASE_FIG).times.map {|i| i % 9 + 1 }.join.to_i
[y_large, y_small].each do |y|
Expand Down
Loading