1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/bigdecimal/lib/bigdecimal/math.rb (atan): reduce loop with

the formula of the double corner.  based on a patch from
  Masahiro Kanai (CanI) in [ruby-dev:39367].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25062 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-09-23 17:08:37 +00:00
parent 12fcef8829
commit 1ef3ac4738
2 changed files with 11 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Thu Sep 24 02:08:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/bigdecimal/lib/bigdecimal/math.rb (atan): reduce loop with
the formula of the double corner. based on a patch from
Masahiro Kanai (CanI) in [ruby-dev:39367].
Thu Sep 24 01:14:18 2009 Yutaka Kanemoto <kanemoto@ruby-lang.org>
* dln.c (aix_loaderror): fixed typo. suppress warnings.

View file

@ -125,11 +125,14 @@ module BigMath
if neg = x < 0
x = -x
end
if x == 1
if x.round(prec) == 1
return pi / (neg ? -4 : 4)
elsif inv = x > 1
x = 1 / x
end
if dbl = x > 0.5
x = (-1 + sqrt(1 + x**2, prec))/x
end
n = prec + BigDecimal.double_fig
y = x
d = y
@ -143,6 +146,7 @@ module BigMath
y += d
r += 2
end
y *= 2 if dbl
y = pi / 2 - y if inv
y = -y if neg
y