mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/bigdecimal/lib/bigdecimal/math.rb (BigMath.E): Use BigMath.exp.
[Feature #6857] [ruby-core:47130] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b09f41587c
commit
b8bbc1a310
2 changed files with 6 additions and 14 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Nov 23 19:52:00 2013 Kenta Murata <mrkn@mrkn.jp>
|
||||
|
||||
* 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@mrkn.jp>
|
||||
|
||||
* ext/bigdecimal/bigdecimal.c (BigMath_s_exp): Optimize the
|
||||
|
|
|
@ -226,19 +226,6 @@ module BigMath
|
|||
#
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue