[Bug #3137] complex.rb changes exceptions of Math

Bug #3137: complex.rb changes exceptions of Math
http://redmine.ruby-lang.org/issues/show/3137

e$B5/I<<Te(B: Yusuke E.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$BC4Ev<Te(B: Keiju Ishitsuka, e$B%+%F%4%je(B: lib, Target version:
1.9.2
ruby -v: ruby 1.9.2dev (2010-04-12 trunk 27317) [i686-linux]

e$B$$$7$D$+$5$se(B
e$B1sF#$G$9!#e(B

[ruby-core:28204] e$B$K$Fe(B Brian F. e$B$,!Ve(Bcomplex e$B$re(B
require e$B$9$k$He(B
Math.atan(nil) e$B$GEj$2$i$l$kNc30$,JQ$o$k!W$H$$$&Js9p$r$7$F$$$^$9!#e(B

$ ./ruby -e ‘p Math.atanh(nil)’
-e:1:in atanh': can't convert nil into Float (TypeError) from -e:1:in

$ ./ruby -rcomplex -e ‘p Math.atanh(nil)’
/home/mame/work/ruby-trunk-local/lib/ruby/1.9.1/cmath.rb:196:in
atanh': undefined method real?’ for nil:NilClass (NoMethodError)
from -e:1:in `’

Ruby e$B%l%Y%k$N%i%$%V%i%j$Oe(B duck typing
e$B$N$?$a$K$`$d$_$K7?%A%'%C%/e(B
e$B$9$Y$-$G$J$$$H$O$$$(!“e(BCMath e$B$OAH$9~$$Ne(B Math
e$B%/%i%9$NCV$-49$($re(B
e$BA0Ds$H$7$F$$$k$N$G!”$J$k$Y$/e(B Math
e$B%/%i%9$N5sF0$rB:=E$7$?J}$,$h$$e(B
e$B$H;W$$$^$7$?!#e(B

e$B0J2<$N%Q%C%A$r%3%_%C%H$7$F$b$$$$$G$7$g$&$+!#e(B

e$B$D$$$G$G$9$,!"e(B[ruby-dev:40953] e$B$b8+$F$/$@$5$$!#e(B

diff --git a/lib/cmath.rb b/lib/cmath.rb
index b23dac2…aa2d9bb 100644
— a/lib/cmath.rb
+++ b/lib/cmath.rb
@@ -27,6 +27,7 @@ module CMath
alias atanh! atanh

def exp(z)

  • z = Float(z)
    if z.real?
    exp!(z)
    else
    @@ -36,9 +37,9 @@ module CMath
    end
    end
  • def log(*args)
  • z, b = args
  • if z.real? and z >= 0 and (b.nil? or b >= 0)
  • def log(z, b = nil)
  • z = Float(z)
  • if z.real? and z >= 0 and (b.nil? or (b = Float(b); b >= 0))
    log!(*args)
    else
    a = Complex(log!(z.abs), z.arg)
    @@ -50,6 +51,7 @@ module CMath
    end

def log2(z)

  • z = Float(z)
    if z.real? and z >= 0
    log2!(z)
    else
    @@ -58,6 +60,7 @@ module CMath
    end

def log10(z)

  • z = Float(z)
    if z.real? and z >= 0
    log10!(z)
    else
    @@ -66,6 +69,7 @@ module CMath
    end

def sqrt(z)

  • z = Float(z)
    if z.real?
    if z < 0
    Complex(0, sqrt!(-z))
    @@ -85,6 +89,7 @@ module CMath
    end

def cbrt(z)

  • z = Float(z)
    if z.real? and z >= 0
    cbrt!(z)
    else
    @@ -93,6 +98,7 @@ module CMath
    end

def sin(z)

  • z = Float(z)
    if z.real?
    sin!(z)
    else
    @@ -102,6 +108,7 @@ module CMath
    end

def cos(z)

  • z = Float(z)
    if z.real?
    cos!(z)
    else
    @@ -111,6 +118,7 @@ module CMath
    end

def tan(z)

  • z = Float(z)
    if z.real?
    tan!(z)
    else
    @@ -119,6 +127,7 @@ module CMath
    end

def sinh(z)

  • z = Float(z)
    if z.real?
    sinh!(z)
    else
    @@ -128,6 +137,7 @@ module CMath
    end

def cosh(z)

  • z = Float(z)
    if z.real?
    cosh!(z)
    else
    @@ -137,6 +147,7 @@ module CMath
    end

def tanh(z)

  • z = Float(z)
    if z.real?
    tanh!(z)
    else
    @@ -145,6 +156,7 @@ module CMath
    end

def asin(z)

  • z = Float(z)
    if z.real? and z >= -1 and z <= 1
    asin!(z)
    else
    @@ -153,6 +165,7 @@ module CMath
    end

def acos(z)

  • z = Float(z)
    if z.real? and z >= -1 and z <= 1
    acos!(z)
    else
    @@ -161,6 +174,7 @@ module CMath
    end

def atan(z)

  • z = Float(z)
    if z.real?
    atan!(z)
    else
    @@ -169,6 +183,7 @@ module CMath
    end

def atan2(y,x)

  • x, y = Float(x), Float(y)
    if y.real? and x.real?
    atan2!(y,x)
    else
    @@ -177,6 +192,7 @@ module CMath
    end

def asinh(z)

  • z = Float(z)
    if z.real?
    asinh!(z)
    else
    @@ -185,6 +201,7 @@ module CMath
    end

def acosh(z)

  • z = Float(z)
    if z.real? and z >= 1
    acosh!(z)
    else
    @@ -193,6 +210,7 @@ module CMath
    end

def atanh(z)

  • z = Float(z)
    if z.real? and z >= -1 and z <= 1
    atanh!(z)
    else


Yusuke E. [email protected]

e$B%A%1%C%He(B #3137 e$B$,99?7$5$l$^$7$?!#e(B (by Marc-Andre L.)

A problem with the patch is that Float(“1.1”) returns 1.1.

In my todo list is “propose strict coercion methods”… I had to code
them up in Matrix

http://redmine.ruby-lang.org/issues/show/3137

e$B%A%1%C%He(B #3137 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

Target version 1.9.2e$B$+$ie(B1.9.xe$B$KJQ99e(B

Hi,

2010e$BG/e(B4e$B7ne(B12e$BF|e(B23:41 Marc-Andre L.
[email protected]:

A problem with the patch is that Float(“1.1”) returns 1.1.

In my todo list is “propose strict coercion methods”… I had to code them up in Matrix

Oh, you are right. Thanks.

I guess “strict coercion” will be good, but it is absolutely new
feature. So, let’s leave #2756 and this ticket to 1.9.3 (or later).


Yusuke ENDOH [email protected]

http://redmine.ruby-lang.org/issues/show/3137

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In the message: “[Bug #3137] complex.rb changes exceptions of Math”,
on Apr/12 23:01(JST) Yusuke E. writes:

e$B1sF#$G$9!#e(B

e$B$I$b$G$9e(B.

     from -e:1:in `<main>'

Ruby e$B%l%Y%k$N%i%$%V%i%j$Oe(B duck typing e$B$N$?$a$K$`$d$_$K7?%A%’%C%/e(B
e$B$9$Y$-$G$J$$$H$O$$$(!“e(BCMath e$B$OAH$9~$$Ne(B Math e$B%/%i%9$NCV$-49$($re(B
e$BA0Ds$H$7$F$$$k$N$G!”$J$k$Y$/e(B Math e$B%/%i%9$N5sF0$rB:=E$7$?J}$,$h$$e(B
e$B$H;W$$$^$7$?!#e(B

e$B$&!<$se(B. e$B$=$&$G$9$M$'e(B…

e$B$?$@e(B, Complex#atanhe$BEy$Ge(B,

-e:1:in `atanh’: can’t convert nil into Float (TypeError)

e$B$H$$$&Nc30$O$U$5$o$7$/$J$$5$$b$7$^$9e(B.
Complex#atanhe$B$N<BAu$rCN$i$J$$$He(B
e$B$o$1$NJ,$+$i$J$$%(%i!<$K$J$C$F$$$k5$$,$7$^$;$se(B?

Math.log(-1) e$B$Ne(B
Math::DomainError: Numerical argument is out of domain - “log”

e$B$h$&$JNc30$NJ}$,$U$5$o$7$$$+$He(B?

e$B0J2<$N%Q%C%A$r%3%_%C%H$7$F$b$$$$$G$7$g$&$+!#e(B

e$BE:IU$N%Q%C%A$@$He(B ze$B$,J#AG?t$N;~$OF0:n$7$^$;$se(B.

e$BNc30$Oe(BMathe$B$H$OJQ$o$j$^$9$,e(B, e$B$=$l$G$h$$$J$ie(B,
NoMethodErrore$B$rJaB*$7$F$=e(B
e$B$l$J$j$NNc30$K$7$F:Fe(Braisee$B$9$k$h$&$K$7$^$9e(B.

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:40967] Re: [Bug #3137] complex.rb changes
exceptions of Math”
on Tue, 13 Apr 2010 14:56:59 +0900, [email protected]
(e$B@PDM7=<ye(B) writes:

|e$B$&!<$se(B. e$B$=$&$G$9$M$‘e(B…
|
|e$B$?$@e(B, Complex#atanhe$BEy$Ge(B,
|
|> -e:1:in `atanh’: can’t convert nil into Float (TypeError)
|
|e$B$H$$$&Nc30$O$U$5$o$7$/$J$$5$$b$7$^$9e(B. Complex#atanhe$B$N<BAu$rCN$i$J$$$He(B
|e$B$o$1$NJ,$+$i$J$$%(%i!<$K$J$C$F$$$k5$$,$7$^$;$se(B?

e$B$=$&!)e(B
nile$BEO$7$F!Ve(Bnile$B$8$c%@%a!W$H8@$o$l$F$k$s$@$+$iL@3N$G$Je(B
e$B$$$+$H!#!Ve(BFloate$B$G$J$/$F$b$$$$$8$c$s!W$C$F$3$H$J$s$@$H;W$&$1e(B
e$B$I!"$=$3$OCWL?E*$G$O$J$$$N$G$O!#e(B

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev:40968] the message: “[ruby-dev:40968] Re: [Bug #3137]
complex.rb changes exceptions of Math”, on Apr/13 15:19(JST) Yukihiro
Matsumoto writes:

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

|e$B$?$@e(B, Complex#atanhe$BEy$Ge(B,
|> -e:1:in `atanh’: can’t convert nil into Float (TypeError)
|e$B$H$$$&Nc30$O$U$5$o$7$/$J$$5$$b$7$^$9e(B. Complex#atanhe$B$N<BAu$rCN$i$J$$$He(B
|e$B$o$1$NJ,$+$i$J$$%(%i!<$K$J$C$F$$$k5$$,$7$^$;$se(B?

e$B$=$&!)e(B nile$BEO$7$F!Ve(Bnile$B$8$c%@%a!W$H8@$o$l$F$k$s$@$+$iL@3N$G$Je(B
e$B$$$+$H!#!Ve(BFloate$B$G$J$/$F$b$$$$$8$c$s!W$C$F$3$H$J$s$@$H;W$&$1e(B
e$B$I!"$=$3$OCWL?E*$G$O$J$$$N$G$O!#e(B

e$B<BAu0F$r8+$k$He(B:

def exp(z)
begin
if z.real?
exp!(z)
else
ere = exp!(z.real)
Complex(ere * cos!(z.imag),
ere * sin!(z.imag))
end
rescue NoMethodError => exp
if exp.name == :real?
raise “error”
end
raise
end
end

e$B$3$s$J46$8$G$9e(B. "error"e$B$N$H$3$m$NNc30$r$I$&$9$k$+$C$FOC$Ge(B,
e$B$3$3$Ge(B

|> -e:1:in `atanh’: can’t convert nil into Float (TypeError)

e$B$A$g$C$HJ,$+$j$E$i$$Nc30$+$H$*$b$C$?$s$G$9$Me(B.

e$B$"$He(B,

def exp(z)
begin
if z.real?
exp!(z)
else
ere = exp!(z.real)
Complex(ere * cos!(z.imag),
ere * sin!(z.imag))
end
rescue NoMethodError => exp
if exp.name == :real?
return exp(Float(z))
end
raise
end
end

e$B$O$"$k$+$J$!e(B… Numerice$B$H$=$N%5%V%/%i%9$7$+e(B, real?
e$B$C$F;}$C$F$^$;$s$Ne(B
e$B$Ge(B, e$B$=$l0J30$N%/%i%9$Oe(BMathe$B$HF1$8?6$kIq$$$H$$$&$3$H$Ge(B,
Floate$B$KJQ49$7$Fe(B
e$B;n$9$O$"$j$+$be(B. e$B$3$l$@$He(B,
CMathe$B$NC4EvHO0O30$Oe(BMathe$B$HF1$87k2L$K$J$j$^$9e(B.
e$B$A$g$C$He(B, e$B$/$I$$5$$,$7$J$/$b$"$j$^$;$s$,e(B…

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:40969] Re: [Bug #3137] complex.rb changes
exceptions of Math”
on Tue, 13 Apr 2010 16:30:38 +0900, [email protected]
(e$B@PDM7=<ye(B) writes:

|e$B$3$s$J46$8$G$9e(B. "error"e$B$N$H$3$m$NNc30$r$I$&$9$k$+$C$FOC$Ge(B, e$B$3$3$Ge(B
|
|>|> -e:1:in `atanh’: can’t convert nil into Float (TypeError)
|
|e$B$A$g$C$HJ,$+$j$E$i$$Nc30$+$H$*$b$C$?$s$G$9$Me(B.

e$B$=$&$+$J$"!#$=$N$^$^!"!Ve(Breal?e$B$,$J$$!W$G$$$$$s$8$c$J$$$G$9$+$M!#e(B

|e$B$"$He(B,
|
| def exp(z)
| begin
| if z.real?
| exp!(z)
| else
| ere = exp!(z.real)
| Complex(ere * cos!(z.imag),
| ere * sin!(z.imag))
| end
| rescue NoMethodError => exp
| if exp.name == :real?
| return exp(Float(z))
| end
| raise
| end
| end
|
|e$B$O$"$k$+$J$!e(B…

e$B$3$l$Oe(B exp(“1.1”) e$B$J$s$F$N$r<u$1IU$1$k$h$&$K$J$C$A$c$&$s$G;?e(B
e$B@.$7$^$;$s!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:40971] Re: [Bug #3137] complex.rb changes
exceptions of Math”
on Tue, 13 Apr 2010 17:05:17 +0900, [email protected]
(e$B@PDM7=<ye(B) writes:

|e$B$=$l$Oe(B, e$B8=9T$N>uBV$G$9e(B. e$B$=$&$8$c$J$/$Fe(B, Mathe$B$HF1$8>e5-$NNc30$K$7$m$C$Fe(B
|e$B8@$o$l$F$$$k$s$G$9$,e(B?
|
|e$B;d$b@Q6KE*$KJQ$($J$/$A$c$C$F5$$b$7$F$$$k$o$1$G$O$J$$$N$Ge(B, rejecte$B$G$b$+e(B
|e$B$^$$$^$;$s$1$Ie(B…
|e$B5/I<<T$N1sF#$5$s$O$I$&$+$Je(B?

e$B$&!<$s!";d$OCfN)$G$9!#$^$"!"e(BFloate$B$r$+$^$;$:$K%*%j%8%J%k$Ne(Bexp
e$B$r8F$V$V$s$K$O<B32$O>/$J$$$N$+$J!#e(B

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev:40970] the message: “[ruby-dev:40970] Re: [Bug #3137]
complex.rb changes exceptions of Math”, on Apr/13 16:47(JST) Yukihiro
Matsumoto writes:

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

|e$B$3$s$J46$8$G$9e(B. “error"e$B$N$H$3$m$NNc30$r$I$&$9$k$+$C$FOC$Ge(B, e$B$3$3$Ge(B
|>|> -e:1:in `atanh’: can’t convert nil into Float (TypeError)
|e$B$A$g$C$HJ,$+$j$E$i$$Nc30$+$H$*$b$C$?$s$G$9$Me(B.
e$B$=$&$+$J$”!#$=$N$^$^!"!Ve(Breal?e$B$,$J$$!W$G$$$$$s$8$c$J$$$G$9$+$M!#e(B

e$B$=$l$Oe(B, e$B8=9T$N>uBV$G$9e(B. e$B$=$&$8$c$J$/$Fe(B,
Mathe$B$HF1$8>e5-$NNc30$K$7$m$C$Fe(B
e$B8@$o$l$F$$$k$s$G$9$,e(B?

e$B;d$b@Q6KE*$KJQ$($J$/$A$c$C$F5$$b$7$F$$$k$o$1$G$O$J$$$N$Ge(B,
rejecte$B$G$b$+e(B
e$B$^$$$^$;$s$1$Ie(B…
e$B5/I<<T$N1sF#$5$s$O$I$&$+$Je(B?

e$B$3$l$Oe(B exp(“1.1”) e$B$J$s$F$N$r<u$1IU$1$k$h$&$K$J$C$A$c$&$s$G;?e(B
e$B@.$7$^$;$s!#e(B

e$B$"!<e(B. e$B$^$A$,$$$G$9e(B

def exp(z)
begin
if z.real?
exp!(z)
else
ere = exp!(z.real)
Complex(ere * cos!(z.imag),
ere * sin!(z.imag))
end
rescue NoMethodError => exp
if exp.name == :real?
return exp!(z)
end
raise
end
end

e$B$G$7$?e(B.

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

e$B1sF#$G$9!#e(B

2010e$BG/e(B4e$B7ne(B13e$BF|e(B17:11 Yukihiro M.
[email protected]:

|e$B5/I<<T$N1sF#$5$s$O$I$&$+$Je(B?

e$B$&!<$s!“;d$OCfN)$G$9!#$^$”!"e(BFloate$B$r$+$^$;$:$K%*%j%8%J%k$Ne(Bexp
e$B$r8F$V$V$s$K$O<B32$O>/$J$$$N$+$J!#e(B

e$B%(%i!<%a%C%;!<%8$NLdBj$G$O$J$/!"Nc30%/%i%9$,JQ$o$k$3$H$@$H;W$$e(B
e$B$^$9!#e(B

def tolerant_exp(x)
begin
Math.exp(x)
rescue TypeError
0
end
end

e$B$H$$$&%3!<%I$N5sF0$,!"e(Bcomplex.rb
e$B$r%m!<%I$9$k$+$I$&$+$GJQ$o$C$Fe(B
e$B$7$^$&$H$$$&!D!D!#$3$s$JNc$,$I$N$/$i$$B8:_$9$k$N$+CN$j$^$;$s$,!#e(B

e$BA0$b8@$C$?$1$I!"e(BNoMethodError e$B$,e(B TypeError

e$B$r7Q>5$7$F$J$$$N$Oe(B

e$B@7W%%9$@$H;W$&e(B

e$B8D?ME*$K$O!"2?$,2?$G$bD>$9$Y$-$H$O;W$C$F$^$;$s$N$G!"e(Breject
e$B$G$be(B
e$B9=$$$^$;$s!#$=$N>l9g$O!“e(B[ruby-core:28204] e$B$Ne(B Brian F.
e$B$KJV;v$re(B
e$B$7$F$”$2$F$b$i$($k$H=u$+$j$^$9!#e(B

2010e$BG/e(B4e$B7ne(B13e$BF|e(B22:42 Yusuke ENDOH [email protected]:

e$BA0$b8@$C$?$1$I!"e(BNoMethodError e$B$,e(B TypeError e$B$r7Q>5$7$F$J$$$N$Oe(B

e$B@7W%%9$@$H;W$&e(B

e$B$b$77Q>5$7$?$H$9$k$H!"%a%=%C%IL>$N4V0c$$$,e(B TypeError e$B$Ge(B
rescue e$B$5$l$F!"e(B
e$BH/8+$7$K$/$/$J$k$s$8$c$J$$$+$J$!!#e(B

e$B$1$$$8$e!w$$$7$D$+$G$9e(B.

In [ruby-dev:40974] the message: “[ruby-dev:40974] Re: [Bug #3137]
complex.rb changes exceptions of Math”, on Apr/13 22:42(JST) Yusuke
ENDOH writes:

e$B1sF#$G$9!#e(B

e$B$H$$$&%3!<%I$N5sF0$,!"e(Bcomplex.rb e$B$r%m!<%I$9$k$+$I$&$+$GJQ$o$C$Fe(B
e$B$7$^$&$H$$$&!D!D!#$3$s$JNc$,$I$N$/$i$$B8:_$9$k$N$+CN$j$^$;$s$,!#e(B

e$B$&!<$se(B. e$B8@$$$?$$$3$H$OJ,$+$i$J$/$O$J$$$G$9$,e(B…

e$B8D?ME*$K$O!"2?$,2?$G$bD>$9$Y$-$H$O;W$C$F$^$;$s$N$G!"e(Breject e$B$G$be(B
e$B9=$$$^$;$s!#$=$N>l9g$O!“e(B[ruby-core:28204] e$B$Ne(B Brian F. e$B$KJV;v$re(B
e$B$7$F$”$2$F$b$i$($k$H=u$+$j$^$9!#e(B

e$B8+$^$7$?e(B.
e$BF1$87oe(B([Bug#1788]e$B$GA%>l$5$s$,0JA0$Ke(Brejecte$B$7$F$$$?$s$G$9e(B
e$B$Me(B. e$B1sF#$5$s$KD>@\8F$S=P$5$l$?$N$Ge(B,
e$BL5>r7oH?<ME*$K=P$F$-$F$7$^$$$^$7$?e(B
e$B$,e(B, cmath.rb e$B$Oe(B,
e$BA%>l$5$s$NC4Ev$,$U$5$o$7$$$HG’<1$7$F$$$^$9e(B.

e$B$H$$$&$o$1$Ge(B, e$B$I$&$9$k$+$OA%>l$5$s$K$*4j$$$7$?$$$N$G$9$,e(B?

__
---------------------------------------------------->> e$B@PDMe(B
e$B7=<ye(B <<—
---------------------------------->> e-mail: [email protected] <<—

Hi,

2010/4/14 Yusuke ENDOH [email protected]:

メンテナがいないのであれば、Marc-Andre がそのうち引き取って
くれそうな気がするので、それでもいいかなと思いました。

I’ll gladly maintain cmath if it can help.

Thanks,

Marc-André

e$B1sF#$G$9!#e(B

2010e$BG/e(B4e$B7ne(B14e$BF|e(B13:32 e$B@PDM7=<ye(B
[email protected]:

e$B8D?ME*$K$O!"2?$,2?$G$bD>$9$Y$-$H$O;W$C$F$^$;$s$N$G!"e(Breject e$B$G$be(B
e$B9=$$$^$;$s!#$=$N>l9g$O!“e(B[ruby-core:28204] e$B$Ne(B Brian F. e$B$KJV;v$re(B
e$B$7$F$”$2$F$b$i$($k$H=u$+$j$^$9!#e(B

e$B8+$^$7$?e(B. e$BF1$87oe(B([Bug#1788]e$B$GA%>l$5$s$,0JA0$Ke(Brejecte$B$7$F$$$?$s$G$9e(B
e$B$Me(B. e$B1sF#$5$s$KD>@\8F$S=P$5$l$?$N$Ge(B, e$BL5>r7oH?<ME*$K=P$F$-$F$7$^$$$^$7$?e(B
e$B$,e(B, cmath.rb e$B$Oe(B, e$BA%>l$5$s$NC4Ev$,$U$5$o$7$$$HG’<1$7$F$$$^$9e(B.

e$B$($C!“$”$l$C!“e(Bcmath.rb
e$B$N%a%s%F%J$O$$$7$D$+$5$s$@$H;W$C$F$$$?e(B
e$B$N$G$9$,!”%a%s%F%J0lMw$K$OA4A3$=$s$J$3$H=q$$$F$J$$$G$9$M!#e(B
e$B40A4$K4*0c$$$7$F$$$^$7$?!#<:Ni$7$^$7$?!#e(B

e$B$H$$$&$o$1$Ge(B, e$B$I$&$9$k$+$OA%>l$5$s$K$*4j$$$7$?$$$N$G$9$,e(B?

e$B$U$J$P$5$s$,%a%s%F%J$r$d$j$^$9$+!)e(B

e$B%a%s%F%J$,$$$J$$$N$G$"$l$P!“e(BMarc-Andre e$B$,$=$N$&$A0z$-<h$C$Fe(B
e$B$/$l$=$&$J5$$,$9$k$N$G!”$=$l$G$b$$$$$+$J$H;W$$$^$7$?!#e(B

e$B%A%1%C%He(B #3137 e$B$,99?7$5$l$^$7$?!#e(B (by tadayoshi funaba)

lib/cmath.rb e$B$OC4Ev$7$J$$$H$$$1$J$$$+$H;W$C$F$$$?$N$G$9$,!"e(B
e$B$3$NA0$N3NG’$G0c$&$H$$$&;v$,H=L@$7$?$N$G0J8e$O4XM?$7$F$^$;$s$G$7$?!#e(B

cmath.rb (e$B$H$$$&$+!“0JA0$+$i$Ne(B complex.rb e$B$N?t3X4X?te(B)
e$B$OB>$K$b2]Bj$,$”$j$=$&$J$s$G!“e(B
e$BEv=i$Oe(B Math e$B$HE}9g$9$k$+>/$J$/$H$be(B C
e$B$G=q$-D>$7$F!”$=$N:]$K$$$m$$$m$H2~A1$G$-$l$Pe(B
e$B$$$$$H;W$C$F$$$^$7$?$,!“$=$&$$$&5!2q$O$J$+$C$?$7!”:#8e$b$J$5$=$&$@$7!"e(B
e$B$=$b$=$b!"e(Brational.c e$B$de(B complex.c e$B$KC4Ev$O$J$$>uBV$G!"e(B
e$B5l$$e(B complex.rb e$B$+$i$N0d;:e(B
(e$B$I$A$i$+$H$$$&$H%^%$%J%9$Ne(B)
e$B$@$1C4Ev$9$k0UL#$O6K$a$FGv$$$o$1$G!"e(B
e$BB>$K$d$j$?$$?M$,5o$k$J$i$d$C$F$b$i$C$F$$$$$H;W$$$^$9!#e(B


http://redmine.ruby-lang.org/issues/show/3137