mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/bigdecimal/lib/bigdecimal/math.rb (BigMath#log): improved
precision and performance. [ruby-dev:41295] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
851a023843
commit
5b20a1398b
2 changed files with 9 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed May 12 15:04:57 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* ext/bigdecimal/lib/bigdecimal/math.rb (BigMath#log): improved
|
||||
precision and performance. [ruby-dev:41295]
|
||||
|
||||
Wed May 12 11:39:10 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* ext/socket/extconf.rb: test all IPPROTO_* constants for recent Win32
|
||||
|
|
|
@ -190,8 +190,10 @@ module BigMath
|
|||
one = BigDecimal("1")
|
||||
two = BigDecimal("2")
|
||||
n = prec + BigDecimal.double_fig
|
||||
if (expo = x.exponent) < 0
|
||||
if (expo = x.exponent) < 0 || expo >= 3
|
||||
x = x.mult(BigDecimal("1E#{-expo}"), n)
|
||||
else
|
||||
expo = nil
|
||||
end
|
||||
x = (x - one).div(x + one,n)
|
||||
x2 = x.mult(x,n)
|
||||
|
@ -206,7 +208,7 @@ module BigMath
|
|||
y += d
|
||||
end
|
||||
y *= two
|
||||
if expo < 0
|
||||
if expo
|
||||
y += log(BigDecimal("10"),prec) * BigDecimal(expo.to_s)
|
||||
end
|
||||
y
|
||||
|
|
Loading…
Reference in a new issue