Skip to content

Commit 0649946

Browse files
committed
Remove workaround of add/sub performance bug
1 parent 9df6e59 commit 0649946

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

lib/bigdecimal/math.rb

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,7 @@ def expm1(x, prec)
574574

575575
return BigDecimal(-1) if exp_prec <= 0
576576

577-
exp = exp(x, exp_prec)
578-
579-
if exp.exponent > prec + BigDecimal.double_fig
580-
# Workaroudn for https://github.com/ruby/bigdecimal/issues/464
581-
exp
582-
else
583-
exp.sub(1, prec)
584-
end
577+
exp(x, exp_prec).sub(1, prec)
585578
end
586579

587580
# erf(decimal, numeric) -> BigDecimal
@@ -608,12 +601,7 @@ def erf(x, prec)
608601
log10_erfc = -xf ** 2 / Math.log(10) - Math.log10(xf * Math::PI ** 0.5)
609602
erfc_prec = [prec + log10_erfc.ceil, 1].max
610603
erfc = _erfc_asymptotic(x, erfc_prec)
611-
if erfc
612-
# Workaround for https://github.com/ruby/bigdecimal/issues/464
613-
return BigDecimal(1) if erfc.exponent < -prec - BigDecimal.double_fig
614-
615-
return BigDecimal(1).sub(erfc, prec)
616-
end
604+
return BigDecimal(1).sub(erfc, prec) if erfc
617605
end
618606

619607
prec2 = prec + BigDecimal.double_fig

0 commit comments

Comments
 (0)