Skip to content

Commit

Permalink
Correctly computing loop iterations in BigDecimal#sqrt (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
z2-2z authored Dec 19, 2023
1 parent 4f4510b commit 5843c89
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -7230,7 +7230,7 @@ VpSqrt(Real *y, Real *x)
y->MaxPrec = Min((size_t)n , y_prec);
f->MaxPrec = y->MaxPrec + 1;
n = (SIGNED_VALUE)(y_prec * BASE_FIG);
if (n < (SIGNED_VALUE)maxnr) n = (SIGNED_VALUE)maxnr;
if (n > (SIGNED_VALUE)maxnr) n = (SIGNED_VALUE)maxnr;

/*
* Perform: y_{n+1} = (y_n - x/y_n) / 2
Expand Down

0 comments on commit 5843c89

Please sign in to comment.