We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0bf63f commit 4120325Copy full SHA for 4120325
lib/bigdecimal/math.rb
@@ -678,9 +678,9 @@ def erfc(x, prec)
678
sum = c_prev.add(c_next, prec)
679
680
2.step do |k|
681
- c = (c_prev.mult(x, prec) + a * c_next).mult(2, prec).mult(x, prec).div(k, prec)
682
- sum = sum.add(c, prec)
683
- c_prev, c_next = c_next, c
+ cn = (c_prev.mult(x, prec) + a * c_next).mult(2, prec).mult(x, prec).div(k, prec)
+ sum = sum.add(cn, prec)
+ c_prev, c_next = c_next, cn
684
break if [c_prev, c_next].all? { |c| c.zero? || (c.exponent < sum.exponent - prec) }
685
end
686
value = sum.mult(scale.mult(exp(-(x + a).mult(x + a, prec), prec), prec), prec)
@@ -778,7 +778,6 @@ def lgamma(x, prec)
778
# if x is close to 1 or 2, increase precision to reduce loss of significance
779
diff1_exponent = (x - 1).exponent
780
diff2_exponent = (x - 2).exponent
781
- extra_prec = [-diff1_exponent, -diff2_exponent, 0].max
782
extremely_near_one = diff1_exponent < -prec2
783
extremely_near_two = diff2_exponent < -prec2
784
test/bigdecimal/test_bigmath.rb
@@ -14,6 +14,13 @@ class TestBigMath < Test::Unit::TestCase
14
MINF = BigDecimal("-Infinity")
15
NAN = BigDecimal("NaN")
16
17
+ def test_no_warning
18
+ assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}")
19
+ begin;
20
+ require 'bigdecimal/math'
21
+ end;
22
+ end
23
+
24
def test_pi
25
assert_equal(
26
BigDecimal("3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117068"),
0 commit comments