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

ruby-changes:31738

From: mrkn <ko1@a...>
Date: Sat, 23 Nov 2013 19:52:45 +0900 (JST)
Subject: [ruby-changes:31738] mrkn:r43817 (trunk): * ext/bigdecimal/lib/bigdecimal/math.rb (BigMath.E): Use BigMath.exp.

mrkn	2013-11-23 19:52:40 +0900 (Sat, 23 Nov 2013)

  New Revision: 43817

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

  Log:
    * ext/bigdecimal/lib/bigdecimal/math.rb (BigMath.E): Use BigMath.exp.
      [Feature #6857] [ruby-core:47130]

  Modified files:
    trunk/ChangeLog
    trunk/ext/bigdecimal/lib/bigdecimal/math.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43816)
+++ ChangeLog	(revision 43817)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Nov 23 19:52:00 2013  Kenta Murata  <mrkn@m...>
+
+	* ext/bigdecimal/lib/bigdecimal/math.rb (BigMath.E): Use BigMath.exp.
+	  [Feature #6857] [ruby-core:47130]
+
 Sat Nov 23 19:46:00 2013  Kenta Murata  <mrkn@m...>
 
 	* ext/bigdecimal/bigdecimal.c (BigMath_s_exp): Optimize the
Index: ext/bigdecimal/lib/bigdecimal/math.rb
===================================================================
--- ext/bigdecimal/lib/bigdecimal/math.rb	(revision 43816)
+++ ext/bigdecimal/lib/bigdecimal/math.rb	(revision 43817)
@@ -226,19 +226,6 @@ module BigMath https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/lib/bigdecimal/math.rb#L226
   #
   def E(prec)
     raise ArgumentError, "Zero or negative precision for E" if prec <= 0
-    n    = prec + BigDecimal.double_fig
-    one  = BigDecimal("1")
-    y  = one
-    d  = y
-    z  = one
-    i  = 0
-    while d.nonzero? && ((m = n - (y.exponent - d.exponent).abs) > 0)
-      m = BigDecimal.double_fig if m < BigDecimal.double_fig
-      i += 1
-      z *= i
-      d  = one.div(z,m)
-      y += d
-    end
-    y
+    BigMath.exp(1, prec)
   end
 end

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

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