summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--ext/bigdecimal/lib/bigdecimal/math.rb6
2 files changed, 11 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index b0c4ef52997..ff359dc1e32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/ext/bigdecimal/lib/bigdecimal/math.rb b/ext/bigdecimal/lib/bigdecimal/math.rb
index dbc058b0b3b..d1e8dbe3266 100644
--- a/ext/bigdecimal/lib/bigdecimal/math.rb
+++ b/ext/bigdecimal/lib/bigdecimal/math.rb
@@ -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