=1B$B$`$i$?$G$9!#=1B(B

On 2010/05/11, at 7:06, _ wanabe wrote:

> Ruby=1B$B$N%H%i%s%/$N=1B(BBigDecimal/math
> atan()=1B$B$K=1B(B1.08=1B$B$rF~$l$k$HLa$jCM$NM-8z7e?t$,B-$j$J$$=1B(B
>=20
> return pi.div(neg ? -2 : 2, prec) if x.infinite?
> return pi / (neg ? -4 : 4) if x.round(prec) =3D=3D 1
> * x =3D 1 / x if inv =3D x > 1
> x =3D (-1 + sqrt(1 + x**2, prec))/x if dbl =3D x > 0.5
>=20
(snip)
>=20
> =1B$B$O$$!"=1B(B
> x =3D BigDecimal("1").div(x, prec)
> =1B$B$G!"$J$*$j$^$9!#=1B(B

=1B$B$3$l$K4X$7$F$O!"0J2<$N=3D$@5$r%3%_%C%H$7$^$9!#=1B(B
=1B$B%P%0$@$H;W$&$N$G=1B(B 1.9.2 =1B$B$N%V%i%s%A$K$b%^!<%8$7$^$9!#=1B(B

diff --git a/ext/bigdecimal/lib/bigdecimal/math.rb =
b/ext/bigdecimal/lib/bigdecimal/math.rb
index eeffde4..07efcbe 100644
--- a/ext/bigdecimal/lib/bigdecimal/math.rb
+++ b/ext/bigdecimal/lib/bigdecimal/math.rb
@@ -125,7 +125,7 @@ module BigMath
     x =3D -x if neg =3D x < 0
     return pi.div(neg ? -2 : 2, prec) if x.infinite?
     return pi / (neg ? -4 : 4) if x.round(prec) =3D=3D 1
-    x =3D 1 / x if inv =3D x > 1
+    x =3D BigDecimal("1").div(x, prec) if inv =3D x > 1
     x =3D (-1 + sqrt(1 + x**2, prec))/x if dbl =3D x > 0.5
     n    =3D prec + BigDecimal.double_fig
     y =3D x
diff --git a/test/bigdecimal/test_bigmath.rb =
b/test/bigdecimal/test_bigmath.rb
index fbeb062..453c47e 100644
--- a/test/bigdecimal/test_bigmath.rb
+++ b/test/bigdecimal/test_bigmath.rb
@@ -57,6 +57,8 @@ class TestBigMath < Test::Unit::TestCase
     assert_in_delta(Math::PI/4, atan(BigDecimal("1.0"), N))
     assert_in_delta(Math::PI/6, atan(sqrt(BigDecimal("3.0"), N) / 3, =
N))
     assert_in_delta(Math::PI/2, atan(PINF, N))
+    =
assert_equal(BigDecimal("0.82384075341863629176935507310251408895934562402=
7952954058347023122539489"),
+                 atan(BigDecimal("1.08"), 72).round(72), =
'[ruby-dev:41257]')
   end
=20
   def test_exp


> y =3D tan(atan(x, prec), prec)
> =
=1B$B$G!"%k!<%W$r2v$7$F!"=1B(Bx=1B$B$H=1B(By=1B$B$NCM$rHf3S$7$F$$$F$?$i!"$=
?$^$?$^H/8+$7$^$7$?!#=1B(B
> =
=1B$B$"!"%H%i%s%/$K$O=1B(Btan=1B$B$O$J$$$N$@$1$I!"=1B(Bsin=1B$B$H=1B(Bcos=1B=
$B$NAH$_9g$o$;$G4V$K9g$o$;$^$7$?!#=1B(B
> tan=1B$B$O%Q%C$H8+!"<}B+$,CY$$$h$&$J$N$G8e2s$7!#=1B(B

BigMath.tan =1B$B$NIT:_$K$D$$$F$O!"=1B(B1.9.3 =
=1B$B$GF3F~$G$-$l$P$d$j$^$9!#=1B(B
=1B$B$3$l$O!"8e$[$I=1B(B Feature =1B$B%A%1%C%H$H$7$FJ,N%$5$;$^$9!#=1B(B

> =1B$B$"$H!"=1B(Bexp=1B$B$N@dBPCM$,Bg$-$/$J$k$H!"La$C$FMh$J$$$N$h$M!#=1B(=
B
> exp(a*b+c) =3D exp(a)**b * exp(c)
> =1B$B$r;H$&$H!"9,$;$K$J$l$k$+$b!#!J$s=3D=3DG\$N0RNO$G!K=1B(B

=1B$B$3$l$H=1B(B

> =
=1B$B$s$G!"=1B(Bpower=1B$B$bA4It$N7e$r7W;;$7$F$46lO+$5$s$J$s$@$,!"=1B(Bint=
eger=1B$B$G$O$J$$$N$@$+$i!"$=3D$s$J$K5$D%$i$J$/$F$b=1B(B..
> =1B$B$H$O!";W$$$^$9!#=1B(B
> exp=1B$B$HF1$8MWNN$G$d$k$H!"<B9TB.EY$,$:$$$V$sB.$/$J$j$^$9!#=1B(B
> =
=1B$B!J=1B(BRuby=1B$B$N%3!<%I$+$i=1B(Bpower=1B$B$r=1B(Bcall=1B$B$9$k$s$@$,=
!"$=3D$l$G$b$H$F$bB.$$!#=1B(B

=1B$B$3$l$H=1B(B

> log=1B$B$O!"=1B(Bexponent=1B$B$,Ii$N>l9g!"=1B(B
> =
=1B$B$r=3Dq$$$F$"$k$+$i!"@5$G=1B(B2=1B$B7e0J>e$N>l9g!"$rDI2C$9$k$HNI$$$G$9=
$M!#=1B(B
> =
exp=1B$B$H=1B(Blog=1B$B$,<BMQHO0OFb$K$J$k$H!"<B?t=1B(B**=1B$B<B?t$,!J<BMQE=
*$K!K;H$($k$h$&$K$J$j$^$9!#=1B(B

=1B$B$3$l$b!"$=3D$l$>$lFHN)$N=1B(B Feature =1B$B%A%1%C%H$KJ,N%$7!"=1B(B
1.9.3 =1B$B$G2~A1$9$k$3$H$rL\;X$7$^$9!#=1B(B

--
Kenta Murata
OpenPGP FP =3D FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

=1B$BK\$r=3Dq$-$^$7$?=1B(B!!
=1B$B!X=1B(BRuby =1B$B5U0z$-%l%7%T!Y=1B(B =
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: mrkn / mrkn.jp
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/