[前][次][番号順一覧][スレッド一覧]

ruby-changes:15805

From: mrkn <ko1@a...>
Date: Tue, 11 May 2010 14:28:54 +0900 (JST)
Subject: [ruby-changes:15805] Ruby:r27735 (ruby_1_9_2): merge from trunk (r27734)

mrkn	2010-05-11 14:28:36 +0900 (Tue, 11 May 2010)

  New Revision: 27735

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27735

  Log:
    merge from trunk (r27734)
    * 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]

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/ext/bigdecimal/lib/bigdecimal/math.rb
    branches/ruby_1_9_2/test/bigdecimal/test_bigmath.rb

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 27734)
+++ ruby_1_9_2/ChangeLog	(revision 27735)
@@ -1,3 +1,10 @@
+Tue May 11 14:26:00 2010  Kenta Murata <mrkn@m...>
+
+	* 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 14:10:36 2010  NAKAMURA Usaku  <usa@r...>
 
 	* time.c (rb_big_abs_find_minbit): get rid of a warning of VC.
Index: ruby_1_9_2/ext/bigdecimal/lib/bigdecimal/math.rb
===================================================================
--- ruby_1_9_2/ext/bigdecimal/lib/bigdecimal/math.rb	(revision 27734)
+++ ruby_1_9_2/ext/bigdecimal/lib/bigdecimal/math.rb	(revision 27735)
@@ -125,7 +125,7 @@
     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
Index: ruby_1_9_2/test/bigdecimal/test_bigmath.rb
===================================================================
--- ruby_1_9_2/test/bigdecimal/test_bigmath.rb	(revision 27734)
+++ ruby_1_9_2/test/bigdecimal/test_bigmath.rb	(revision 27735)
@@ -57,6 +57,8 @@
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]