From 74365313f7db803628c75644c558ca60a64768ff Mon Sep 17 00:00:00 2001 From: mrkn Date: Tue, 11 May 2010 05:11:59 +0000 Subject: * ext/bigdecimal/lib/bigdecimal/math.rb (atan), test/bigdecimal/test_bigmath.rb (test_atan): explicitly specify the precision for calculating a reciprocal number of an argument. [Bug #3267] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ ext/bigdecimal/lib/bigdecimal/math.rb | 2 +- test/bigdecimal/test_bigmath.rb | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 77a99018a1..b35128c1e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue May 11 13:46:00 2010 Kenta Murata + + * ext/bigdecimal/lib/bigdecimal/math.rb (atan), + test/bigdecimal/test_bigmath.rb (test_atan): explicitly specify + the precision for calculating a reciprocal number of an argument. + [Bug #3267] + Tue May 11 11:49:44 2010 Nobuyoshi Nakada * ext/sdbm/sdbm.h (DBM): large file support on win32. diff --git a/ext/bigdecimal/lib/bigdecimal/math.rb b/ext/bigdecimal/lib/bigdecimal/math.rb index eeffde4e68..07efcbe099 100644 --- a/ext/bigdecimal/lib/bigdecimal/math.rb +++ b/ext/bigdecimal/lib/bigdecimal/math.rb @@ -125,7 +125,7 @@ module BigMath x = -x if neg = x < 0 return pi.div(neg ? -2 : 2, prec) if x.infinite? return pi / (neg ? -4 : 4) if x.round(prec) == 1 - x = 1 / x if inv = x > 1 + x = BigDecimal("1").div(x, prec) if inv = x > 1 x = (-1 + sqrt(1 + x**2, prec))/x if dbl = x > 0.5 n = prec + BigDecimal.double_fig y = x diff --git a/test/bigdecimal/test_bigmath.rb b/test/bigdecimal/test_bigmath.rb index fbeb06221b..453c47ec6b 100644 --- a/test/bigdecimal/test_bigmath.rb +++ b/test/bigdecimal/test_bigmath.rb @@ -57,6 +57,8 @@ class TestBigMath < Test::Unit::TestCase assert_in_delta(Math::PI/4, atan(BigDecimal("1.0"), N)) assert_in_delta(Math::PI/6, atan(sqrt(BigDecimal("3.0"), N) / 3, N)) assert_in_delta(Math::PI/2, atan(PINF, N)) + assert_equal(BigDecimal("0.823840753418636291769355073102514088959345624027952954058347023122539489"), + atan(BigDecimal("1.08"), 72).round(72), '[ruby-dev:41257]') end def test_exp -- cgit v1.2.3