Math::atan2(0, 0) on ruby 1.9.2

e$B5WJ]$G$9!#e(B

ruby 1.9.2 e$B$G$Oe(B Math::atan2(0, 0)
e$B$,Nc30$r>e$2$k$h$&$KJQ99$5$l$F$$$^$9e(B
e$B$,!“85$KLa$7$?$[$&$,NI$/$”$j$^$;$s$+!)e(B

e$B0J2<!"@bL@!#e(B

1.9.1 e$B0JA0$G$Oe(B Math::atan2(0, 0)
e$B$O0z?t$NId9f$K$h$C$F!"0J2<$N$h$&$JCMe(B
e$B$rLa$7$F$$$^$7$?!#e(B(Linux & Windows e$B$G;n83e(B)

Math::atan2(+0.0, +0.0) -> +0.0
Math::atan2(+0.0, -0.0) -> +Math::PI
Math::atan2(-0.0, +0.0) -> -0.0
Math::atan2(-0.0, -0.0) -> -Math::PI

1.9.2 e$B$G$Oe(B r26785 e$B$NJQ99$Ge(B Math::DomainError
e$BNc30$r>e$2$k$h$&$KJQ99$5e(B
e$B$l$F$$$^$7$?!#e(B

e$B1Q8lHGe(B Wikipadia e$B$Ne(B atan2 e$B$r8+$?$H$3$m!"e(Batan2(0, 0)
e$B$NLa$jCM$Oe(B
undefined e$B$G!"e(BSingle UNIX Specification version 2 e$B$Ne(B atan2
e$B$NDj5A$K$Oe(B

If both arguments are 0.0, an implementation-dependent value is
returned
and errno may be set to [EDOM].
(http://opengroup.org/onlinepubs/007908775/xsh/atan2.htmle$B$h$j0zMQe(B)

e$B$H=q$+$l$F$$$k$N$G!"$3$N5-=R$K=>$&$HNc30$r>e$2$k$N$b$"$j$+$J$H$O;W$C$?e(B
e$B$1$I!"e(B2004e$BG/HG$Ne(B Single UNIX Specification version 3
e$B$G$O!"e(B
(2001e$BG/HG$O$_$D$+$i$J$+$C$?e(B…)

If y is e$B!^e(B0 and x is -0, e$B!^&Pe(B shall be returned.
If y is e$B!^e(B0 and x is +0, e$B!^e(B0 shall be returned.
(http://www.opengroup.org/onlinepubs/000095399/functions/atan2.htmle$B$h$j0zMQe(B)

e$B$HJQ99$5$l$F$$$?!#>e5-$Ne(B Windows & Linux
e$B$G$N;n837k2L$O$3$N5-=R$K=>$Ce(B
[email protected]$H;W$o$l$k!#e(B

e$B:G6a$N%7%9%F%`$G$Oe(B atan2(0, 0)
e$B$NLa$jCM$,<BAu0MB8$G$O$J$/$J$C$F$-$F$*e(B
e$B$j!"$^$?!“e(B"errno may be set to [EDOM].”
e$B$H$$$&5-=R$b>C$($F$$$k$N$G!“e(B
Math::atan2(0, 0) e$B$G0z?t$,N>J}$H$be(B 0 e$B$J$i$Pe(B
Math::DomainError e$B$r>e$2$ke(B
e$B$H$$$&$N$O;_$a$?$[$&$,NI$$$H;W$&$N$G$9$,!”$I$&$G$7$g$&$+!)e(B

1.9.2
e$B$K$7$?$i$$$-$J$jNc30$,>e$,$k$h$&$K$J$j$S$C$/$j$7$?$b$N$Ge(B…e$B!#e(B

e$B$`$i$?$G$9!#e(B

e$B$3$NJQ99$re(B 1.9.2 e$B$XE,MQ$7$?$N$O;d$G$9!#e(B

On 2010/08/22, at 17:59, KUBO Takehiro wrote:

e$B5WJ]$G$9!#e(B

ruby 1.9.2 e$B$G$Oe(B Math::atan2(0, 0) e$B$,Nc30$r>e$2$k$h$&$KJQ99$5$l$F$$$^$9e(B
e$B$,!“85$KLa$7$?$[$&$,NI$/$”$j$^$;$s$+!)e(B

e$B5WJ]$5$s$,5$$K$5$l$F$$$k;vJA$b4^$a!"H>G/$[$IA0$Ke(B
[ruby-core:28206] Is Math module a wrapper of libm?
[email protected]$5$l$F$$$^$9!#e(B

[ruby-core:28206] e$B$+$i;O$^$k%9%l%C%I$N:GBg$N<}3O$O!"e(B
Math e$B$N5sF0$r%W%i%C%H%U%)!<%`Hs0MB8$K$G$-$?$3$H$G$7$?!#e(B
e$B;d$,e(B [ruby-core:28286] e$B$GDs<($7$?e(B patch
e$B$,8=:_$N5sF0$N%Y!<%9$K$J$C$F$$$^$9!#e(B
e$B$$$^FI$_JV$9$H!"5WJ]$5$s$,[email protected]$5$l$F$$$ke(B atan2
e$B$N5sF0$O$7$C$+$je(B
“needs more discussions” e$B$HCm5-$5$l$F$$$^$7$?!#e(B

e$BLdBj$N5sF0$b4^$a!"e(B[ruby-core:28302] e$B$Ge(B Marc-Andre e$B$,e(B
final answer e$B$re(B
e$B5a$a$^$7$?$,[email protected]$O=P$:!"e(B1.9.2
e$B$N5sF0$H$7$F:NMQ$5$l$?<!Bh$G$9!#e(B

e$B$3$N$h$&$JGX7J$,$"$j$^$9$N$G;d$O8=:[email protected]*$K$J$l$^$;$s!#e(B
e$B$7$+$7!"2>$K8=:
$N5sF0$rJQ99$7$?$$>l9g$K2?$r$9$Y$-$+$r9M$($k$H!"e(B

On 2010/08/22, at 17:59, KUBO Takehiro wrote:

e$B:G6a$N%7%9%F%`$G$Oe(B atan2(0, 0) e$B$NLa$jCM$,<BAu0MB8$G$O$J$/$J$C$F$-$F$*e(B
e$B$j!"$^$?!“e(B"errno may be set to [EDOM].” e$B$H$$$&5-=R$b>C$($F$$$k$N$G!“e(B
Math::atan2(0, 0) e$B$G0z?t$,N>J}$H$be(B 0 e$B$J$i$Pe(B Math::DomainError e$B$r>e$2$ke(B
e$B$H$$$&$N$O;_$a$?$[$&$,NI$$$H;W$&$N$G$9$,!”$I$&$G$7$g$&$+!)e(B

e$B$3$N0zMQ$G5WJ]$5$s$,6D$C$F$$$ke(B “e$B:G6a$N%7%9%F%`e(B”
e$B$K4^$^$l$J$$4D6-$r$I$&07$&$Y$-$+$^$G4^$a!“e(B
e$B5WJ]$5$s$,E,@[email protected]$H9M$($ke(B patch
e$B$r8f<+?H$G:[email protected]$7!”$=$l$rDs0F$7$FD:[email protected]$r3+;O$G$-$k$H;W$$$^$9!#e(B

e$B;v$NH/C<$Oe(B ruby-core [email protected]$C$?$N$G!"e(Bpatch
e$B$NDs0F$J$I$NB3$-$O$=$A$i$G9T$&$[$&$,NI$$$+$b$7$l$^$;$s!#e(B


Kenta M.
OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54 98C1 CEFE 8AFB 6081 B062

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

e$B5WJ]$G$9!#e(B

2010/8/22 Kenta M. [email protected]:

ruby 1.9.2 e$B$G$Oe(B Math::atan2(0, 0) e$B$,Nc30$r>e$2$k$h$&$KJQ99$5$l$F$$$^$9e(B
e$B$,!“85$KLa$7$?$[$&$,NI$/$”$j$^$;$s$+!)e(B

e$B5WJ]$5$s$,5$$K$5$l$F$$$k;vJA$b4^$a!"H>G/$[$IA0$Ke(B
[ruby-core:28206] Is Math module a wrapper of libm? [email protected]$5$l$F$$$^$9!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#0l1~!"e(Bgoogle e$B$Ge(B ruby atan2
e$B$G8!:w$7$F$O$$$?$N$G$9$,!“e(B
e$B8+Mn$H$7$F$$$^$7$?!#e(BML
e$B%”!<%+%$%V$K8BDj$7$F8!:w$9$l$PNI$+$C$?$N$+e(B…e$B!#e(B

e$B:G6a$N%7%9%F%`$G$Oe(B atan2(0, 0) e$B$NLa$jCM$,<BAu0MB8$G$O$J$/$J$C$F$-$F$*e(B
e$B$j!"$^$?!“e(B"errno may be set to [EDOM].” e$B$H$$$&5-=R$b>C$($F$$$k$N$G!“e(B
Math::atan2(0, 0) e$B$G0z?t$,N>J}$H$be(B 0 e$B$J$i$Pe(B Math::DomainError e$B$r>e$2$ke(B
e$B$H$$$&$N$O;_$a$?$[$&$,NI$$$H;W$&$N$G$9$,!”$I$&$G$7$g$&$+!)e(B

e$B$3$N0zMQ$G5WJ]$5$s$,6D$C$F$$$ke(B “e$B:G6a$N%7%9%F%`e(B” e$B$K4^$^$l$J$$4D6-$r$I$&07$&$Y$-$+$^$G4^$a!“e(B
e$B5WJ]$5$s$,E,@[email protected]$H9M$($ke(B patch e$B$r8f<+?H$G:[email protected]$7!”$=$l$rDs0F$7$FD:[email protected]$r3+;O$G$-$k$H;W$$$^$9!#e(B

e$BJQ99$NL\E*$,%W%i%C%H%U%)!<%`Hs0MB8$K$9$k$H$$$&$3$H$G$7$?$i!"85$KLa$9$H$$$&e(B
e$B$N$O40A4$K5Q2<$G$9$M!#$H$J$k$H!"96$a$k$H$7$?$i!"e(B[ruby-core:28302]e$B$Ne(B
“Ruby 1.9 deviates from SUSv3 in a few corner cases:” e$B$+$J!#e(B

e$B;v$NH/C<$Oe(B ruby-core [email protected]$C$?$N$G!"e(Bpatch e$B$NDs0F$J$I$NB3$-$O$=$A$i$G9T$&$[$&$,NI$$$+$b$7$l$^$;$s!#e(B

e$BN;2r$G$9!#<j85$N0F7o$,=*$o$C$?$i!"$d$C$F$_$^$9!#e(B

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

e$B$3$N5sF0JQ99$K;j$k$-$C$+$1$r:n$C$?<Te(B [ruby-core:28206]
e$B$G$9!#e(B

2010e$BG/e(B8e$B7ne(B22e$BF|e(B17:59 KUBO Takehiro [email protected]:

e$B$H=q$+$l$F$$$k$N$G!"$3$N5-=R$K=>$&$HNc30$r>e$2$k$N$b$"$j$+$J$H$O;W$C$?e(B
e$B$1$I!"e(B2004e$BG/HG$Ne(B Single UNIX Specification version 3 e$B$G$O!"e(B

e$B;d$b:G=i$O!VLUL\E*$Ke(B SUSv3
e$B$r<jK$K$9$l$P$$$$!W$H;W$C$F$$$?$N$G$9$,!"e(B

e$B!{e(B e$B%(%i!<$N%$%s%?!<%U%’%$%9$,??;w$G$-$J$$e(B
(SUSv3 e$B$Oe(B C [email protected]%Y!<%9$J$N$G!"!Ve(Berrno e$B$Ke(B EDOM
[email protected]_Dj$7$D$DCM$rJV$9!We(B
e$B$H$$$&$3$H$,$G$-$k$1$l$I!"e(BRuby [email protected]$H!Ve(BError::EDOM
e$BNc30$rEj$2$D$DCM$re(B
e$BJV$9!W$H$$$&$3$H$,$G$-$J$$e(B)

e$B!{e(B SUSv3 e$B$K$b%P%0$,$"$k$C$]$$e(B
(e$BNc$($Pe(B SUSv3 [email protected]$He(B lgamma(-inf) e$B$,e(B +inf
e$B$rJV$9$H5,Dj$5$l$F$$$k$,!"e(B
e$B$3$l$OB?J,L$Dj5A$,@52re(B)

e$B$J$I$NM}M3$G!"e(BSUSv3
e$B$K=`5r$9$l$P$$$$$H$$$&OC$G$O$J$/$J$C$F$$$^$9!#e(B

e$B:G6a$N%7%9%F%`$G$Oe(B atan2(0, 0) e$B$NLa$jCM$,<BAu0MB8$G$O$J$/$J$C$F$-$F$*e(B
e$B$j!"$^$?!“e(B"errno may be set to [EDOM].” e$B$H$$$&5-=R$b>C$($F$$$k$N$G!“e(B
Math::atan2(0, 0) e$B$G0z?t$,N>J}$H$be(B 0 e$B$J$i$Pe(B Math::DomainError e$B$r>e$2$ke(B
e$B$H$$$&$N$O;_$a$?$[$&$,NI$$$H;W$&$N$G$9$,!”$I$&$G$7$g$&$+!)e(B

e$B$H$$$&$o$1$Ge(B SUSv3
e$B$H$N5sF0$N0c$$$O:,5r$K$J$i$J$$$N$G$9$,!"!V:#[email protected]$He(B
e$Be:$$k$3$H$,$"$k!W$J$I$H$$$&OC$,$"$l$P!"M-NO$J:,5r$K$J$k$H;W$$$^$9!#e(B
e$B$3$N5sF0JQ99$K5$$,$D$$$?>[email protected]@$7$FD:$1$k$H$$$$$+$b$7$l$^$;$s!#e(B

2010e$BG/e(B8e$B7ne(B22e$BF|e(B21:00 Kenta M. [email protected]:

e$B$3$N0zMQ$G5WJ]$5$s$,6D$C$F$$$ke(B “e$B:G6a$N%7%9%F%`e(B” e$B$K4^$^$l$J$$4D6-$r$I$&07$&$Y$-$+$^$G4^$a!“e(B
e$B5WJ]$5$s$,E,@[email protected]$H9M$($ke(B patch e$B$r8f<+?H$G:[email protected]$7!”$=$l$rDs0F$7$FD:[email protected]$r3+;O$G$-$k$H;W$$$^$9!#e(B

e$B$d$k$H$7$?$i!"$3$s$J46$8!)e(B

diff --git a/math.c b/math.c
index 23bca55…b73ae30 100644
— a/math.c
+++ b/math.c
@@ -55,7 +55,10 @@ math_atan2(VALUE obj, VALUE y, VALUE x)
Need_Float2(y, x);
dx = RFLOAT_VALUE(x);
dy = RFLOAT_VALUE(y);

  • if (dx == 0.0 && dy == 0.0) domain_error(“atan2”);
  • if (dx == 0.0 && dy == 0.0) {
  •   if (!signbit(dx)) return DBL2NUM(dy);
    
  •   return DBL2NUM(atan2(dy, -1.0));
    
  • }
    if (isinf(dx) && isinf(dy)) domain_error(“atan2”);
    return DBL2NUM(atan2(dy, dx));
    }

e$B5$$,$D$$$F$$$J$+$C$?$1$I!"$?$V$s!"$3$NJQ99$N$;$$$G!"e(B
Complex(-0.0, 0.0).arg e$B$,%(%i!<$K$J$k$h$&$K$J$C$?$H;W$$$^$9!#e(B

(-0.0).arg #=> 3.141592653589793

e$B$G$"$k$h$&$K!"85!9e(B Complex(-0.0, 0.0).arg
e$B$bF1$87k2L$K$J$k$H4|BT$7$F$$e(B
e$B$^$7$?!#e(B

[email protected]$bDI$$$+$1$F$$$J$$$N$G$h$/$o$+$j$^$;$s$,!"$H$j$"$($:0JA0$N?6Iq$$$Ke(B
e$BLa$k$3$H$r4uK>$7$F$*$-$^$9!#e(B

e$B5WJ]$G$9!#e(B

2010/8/22 Yusuke ENDOH [email protected]:

e$B$J$I$NM}M3$G!"e(BSUSv3 e$B$K=`5r$9$l$P$$$$$H$$$&OC$G$O$J$/$J$C$F$$$^$9!#e(B

e$B$J$k$[$Ie(B…e$B!#:$$C$?!#e(B

e$B:G6a$N%7%9%F%`$G$Oe(B atan2(0, 0) e$B$NLa$jCM$,<BAu0MB8$G$O$J$/$J$C$F$-$F$*e(B
e$B$j!"$^$?!“e(B"errno may be set to [EDOM].” e$B$H$$$&5-=R$b>C$($F$$$k$N$G!“e(B
Math::atan2(0, 0) e$B$G0z?t$,N>J}$H$be(B 0 e$B$J$i$Pe(B Math::DomainError e$B$r>e$2$ke(B
e$B$H$$$&$N$O;_$a$?$[$&$,NI$$$H;W$&$N$G$9$,!”$I$&$G$7$g$&$+!)e(B

e$B$H$$$&$o$1$Ge(B SUSv3 e$B$H$N5sF0$N0c$$$O:,5r$K$J$i$J$$$N$G$9$,!"!V:#[email protected]$He(B
e$Be:$$k$3$H$,$"$k!W$J$I$H$$$&OC$,$"$l$P!"M-NO$J:,5r$K$J$k$H;W$$$^$9!#e(B
e$B$3$N5sF0JQ99$K5$$,$D$$$?>[email protected]@$7$FD:$1$k$H$$$$$+$b$7$l$^$;$s!#e(B

e$B$(!<$H!"!Ve:$$k$3$H!W$H$$$&OC$O$"$j$^$;$s!#$b$H$b$He(B atan2()
e$B$r<Be(B
e$B%"%W%j$G;H$C$?$3$H$O0lEY$b$J$$$7e(B…e$B!#e(B

[email protected]@$9$k$H!";d$N:n$C$F$$$ke(B ruby-oci8 e$B$H$$$&e(B
Oracle e$B%i%$e(B
e$B%V%i%j$N%F%9%H%1!<%9$N<:GT$,H/C<$G$7$?!#e(BOracle
e$B$N%/%i%$%"%s%H%i%$%V%ie(B
e$B%j$K$Oe(B10e$B?J?te([email protected]:EY$r$b$De(B NUMBER
e$B7?e(B(e$BFbItE*$K$Oe(B100e$B?J?te(B19e$B7ee(B)e$B$KBP$9$ke(B
e$B?tCM4X?t$,Dj5A$5$l$F$$$F!"e(BOCIe$B4X?te(B OCINumberArcTan2()
e$B$KBP1~$9$ke(B rubye$BB&e(B
e$B$N4X?t$H$7$Fe(BOCI8::Math::atan2()
e$B$,Dj5A$5$l$F$$$^$9!#$3$N4X?t$NF0:n%F%9e(B
e$B%H$H$7$F1i;;7k2L$NHf3S$N$?$a$Ke(B Math::atan2()
e$B$r;HMQ$7$F$$$?$o$1$G$9!#e(B
e$B$G!“e(BMath::atan2(0, 0)
e$B$,Nc30$r>e$2$k$h$&$K$J$C$?7k2L!”%F%9%H%1!<%9$K<:e(B
e$BGT$9$k$h$&$K$J$C$?$H!#e(B

e$B$`$7$m!“Nc30$,>e$,$k$h$&$K$J$C$Fe(B ruby-oci8
e$BE*$K$O9%ET9g$J$3$H$b$”$j$^e(B
e$B$9!#85!9!"e(BOCINumberArcTan2() e$B$OFsHVL$N?tCM$,e(B 0
e$B$N$H$-$O%(%i!<$K$J$k;Ee(B
e$BMM$G$7$F!"e(BMath::atan2()
e$B$NF0:n$K9g$o$;$k$?$a$NFCJL=hM}$rF~$l$F$?$N$G$9e(B
e$B$,!"e(BOracle e$B$Ne(B NUMBER e$B7?$K$Oe(B +0/-0
e$B$N6hJL$,$J$$$N$G!"e(B100%e$B9g$o$;$k$3$H$Oe(B
e$BIT2DG=$G$7$?!#$7$+$7!"e(Bruby e$B$Ne(B Math::atan2(0, 0)
e$B$,Nc30$r>e$2$k$h$&$K$J$Ce(B
e$B$?$N$G!"F1$8F0:n$r$5$;$k$3$H$,2DG=$H$J$C$?!#$3$&$$$&[email protected]$+$i8+$k$H5U$K9%e(B
e$BET9g$J$o$1$G$9!#e(B

e$BA0$N%a!<%k$Ge(B

e$BN;2r$G$9!#<j85$N0F7o$,=*$o$C$?$i!"$d$C$F$_$^$9!#e(B
e$B$H=q$$$?$1$I!"!Ve(BSUSv3
e$B$H$N5sF0$N0c$$$O:,5r$K$J$i$J$$!W$H$$$&OC$r4^$a$Fe(B
e$B$b$&>/$79M$($F$+$i$K$7$^$9!#e(B(e$B7k6I$d$i$J$$$H$$$&[email protected]$K$J$k$+$be(B)

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

atan2 e$B$O6K:BI8JQ49$K;H$o$l$k$N$G!“e(B[hypot(x, y), atan2(x, y)]
e$B$,e(B
x = y = 0 e$B$N;~$K%(%i!<$K$J$k$N$OITJX!”$H$$$&$h$&$J$3$H$,e(B FreeBSD
e$B$Ne(B manpage e$B$K=q$$$F$"$j$^$7$?!#e(B
e$B$3$Ne(B rationale e$B$O8D?ME*$K$OG<[email protected]$G$-$^$9!#e(B

e$B$^$?!"$$$/$D$+e(B regression
e$B$b0z$-5/$3$7$F$$$k$h$&$J$N$G!"e(Batan2 e$B$Ke(B
e$B4X$7$F$Oe(B SUSv3 e$B$K=>$C$F$*$/$H$h$$$N$G$O$J$$$G$7$g$&$+!#e(B
1.9.2-pX e$B$GD>$9$+!"e(B1.9.3 e$B$GD>$9$+$OG:$^$7$$$H$3$m$G$9$,!#e(B

e$B$`$i$?$G$9!#e(B

On 2010/08/23, at 2:29, Yusuke ENDOH wrote:

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

atan2 e$B$O6K:BI8JQ49$K;H$o$l$k$N$G!“e(B[hypot(x, y), atan2(x, y)] e$B$,e(B
x = y = 0 e$B$N;~$K%(%i!<$K$J$k$N$OITJX!”$H$$$&$h$&$J$3$H$,e(B FreeBSD
e$B$Ne(B manpage e$B$K=q$$$F$"$j$^$7$?!#e(B
e$B$3$Ne(B rationale e$B$O8D?ME*$K$OG<[email protected]$G$-$^$9!#e(B

e$B$^$?!"$$$/$D$+e(B regression e$B$b0z$-5/$3$7$F$$$k$h$&$J$N$G!"e(Batan2 e$B$Ke(B
e$B4X$7$F$Oe(B SUSv3 e$B$K=>$C$F$*$/$H$h$$$N$G$O$J$$$G$7$g$&$+!#e(B

e$B$J$k$[$I!“0lM}$”$j$^$9$M!#e(B

1.9.2-pX e$B$GD>$9$+!"e(B1.9.3 e$B$GD>$9$+$OG:$^$7$$$H$3$m$G$9$,!#e(B

e$B$3$N%?%$%_%s%0$G5sF0$rJQ99$9$k$N$G$7$?$ie(B 1.9.2-pX e$B$Ke(B
e$B%P%C%/%]!<%H$7$?$$5$$,$7$^$9!#e(B


Kenta M.
OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54 98C1 CEFE 8AFB 6081 B062

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

e$B5WJ]$G$9!#e(B

2010/8/23 Yusuke ENDOH [email protected]:

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

atan2 e$B$O6K:BI8JQ49$K;H$o$l$k$N$G!“e(B[hypot(x, y), atan2(x, y)] e$B$,e(B
x = y = 0 e$B$N;~$K%(%i!<$K$J$k$N$OITJX!”$H$$$&$h$&$J$3$H$,e(B FreeBSD
e$B$Ne(B manpage e$B$K=q$$$F$"$j$^$7$?!#e(B
e$B$3$Ne(B rationale e$B$O8D?ME*$K$OG<[email protected]$G$-$^$9!#e(B

e$B$^$?!"$$$/$D$+e(B regression e$B$b0z$-5/$3$7$F$$$k$h$&$J$N$G!"e(Batan2 e$B$Ke(B
e$B4X$7$F$Oe(B SUSv3 e$B$K=>$C$F$*$/$H$h$$$N$G$O$J$$$G$7$g$&$+!#e(B

e$B$$$C$=$N$3$H!“e(BJava
e$B$N;EMM$r??;w$9$k$H$$$&$N$b$”$j$+$b$7$l$J$$!#e(B
e$B$=$&$9$l$P!"!V%(%i!<$N%$%s%?!<%U%’%$%9$,??;w$G$-$J$$!W$H$$$&LdBj$O$J$/e(B
e$B$J$j$^$9$7!"$^$?!“e(BJRuby e$BB&$H$7$F$O$=$N$[$&$,3Z$G$7$g$&!#e(B
e$B$^$”!“e(BSUSv3 e$B$He(B Java
e$B$N;EMM$r$D$-$”$o$;$F$+$i$G$J$$$H$O$C$-$j$7$?e(B
[email protected]$($J$$$1$Ie(B…e$B!#e(B
(e$B5-21$N8B$j$G$Oe(B atan2(e$B!^e(B0, e$B!^e(B0) e$B$NLa$jCM$Oe(B SUSv3
e$B$He(B Java [email protected]$C$?e(B)

e$B:#=5Kv$K$G$bD4$Y$F$_$^$9!#e(B


e$B$3$N<0$+$iMh$F$$$k$h$&$G$9!#e(BWikipedia [3] e$B$K$"$ke(B atan2 e$B$Ne(B3e$B<!85%0%i%U$r8+$l$Pe(B
Scheme e$B$NDj5A$r:NMQ$9$k;v$,E,@Z$J$h$&$K46$8$^$9!#e(B

[email protected]$3&$Ge(B +0, -0, 0 e$B$N#3$D$r6hJL$G$-$k$N$G$7$?$C$1!)e(B

e$B$`$i$?$G$9!#e(B

On 2010/08/23, at 23:05, KUBO Takehiro wrote:

e$B$^$?!"$$$/$D$+e(B regression e$B$b0z$-5/$3$7$F$$$k$h$&$J$N$G!"e(Batan2 e$B$Ke(B
e$B4X$7$F$Oe(B SUSv3 e$B$K=>$C$F$*$/$H$h$$$N$G$O$J$$$G$7$g$&$+!#e(B

e$B$$$C$=$N$3$H!“e(BJava e$B$N;EMM$r??;w$9$k$H$$$&$N$b$”$j$+$b$7$l$J$$!#e(B

e$B2?$N:,5r$b$J$/C;MmE*$Ke(B Java
e$B$K9g$o$;$h$&$H$$$&9M$($K$O;?F1$G$-$^$;$s$7!"e(B
e$B$J$<$=$3$Ge(B Java
[email protected]$1e(Be$B$,=P$F$/$k$N$+$bNI$/J,$+$j$^$;$s!#e(B

Math.atan2
e$B$O?t3X$N4X?t$G$9$+$i!"[email protected]$1?t3XE*$K9M$($?$$$G$9$7!"e(B
e$BB>[email protected]$r;29M$K$9$k$J$ie(B Java
[email protected]$b8+$?$[$&$,NI$$$G$7$g$&!#e(B

Common Lisp [1] e$B$He(B Scheme (R6RS) [2]
e$B$rD4$Y$F$_$k$H!"<!$N$h$&$K$J$C$F$$$^$9e(B:

Common Lisp e$B$N>l9ge(B

x y atan2(x, y)

+0 +0 +0
+0 -0 -0
-0 +0 +pi
-0 -0 -pi

Scheme e$B$N>l9ge(B (R6RS)

x y atan2(x, y)

+0 +0 +0
+0 -0 -0
-0 +0 +pi
-0 -0 -pi
0 +0 pi/2
0 -0 -pi/2

Common Lisp e$B$Oe(B SUSv3 e$B$HF1$8$G!"e(BScheme
e$B$O>l9gJ,$1$,e(B2e$B$DA}$($F$$$^$9!#e(B
Haskell e$B$Ne(B atan2 e$B$Oe(B Common Lisp e$B$HF1$8$G$7$?!#e(B

e$B$A$J$_$Ke(B Mathematica e$B$O!">e5-$NCM$Oe(B indefinite

e$B$H$7$FCM0h$,JV$C$F$-$^$9!#e(B

e$B$3$l$i$NCM$,$I$3$+$iMh$?$N$+$r9M$($k$H!"$I$&$be(B

atan2(e$B!^e(B0, e$B!^e(B0) = lim_{x->e$B!^e(B0} lim_{y->e$B!^e(B0}
atan2(x, y) (e$BJ#9fF1=ge(B)

e$B$3$N<0$+$iMh$F$$$k$h$&$G$9!#e(BWikipedia [3] e$B$K$"$ke(B atan2
e$B$Ne(B3e$B<!85%0%i%U$r8+$l$Pe(B
Scheme e$B$NDj5A$r:NMQ$9$k;v$,E,@Z$J$h$&$K46$8$^$9!#e(B

[1]
http://www.lispworks.com/documentation/HyperSpec/Body/f_asin_.htm#atan
[2]
http://practical-scheme.net/wiliki/wiliki2.cgi?R6RS:翻訳:R6RS:11.7.3.2%20Transcendental%20functions
[3] http://en.wikipedia.org/wiki/Atan2#Variations


Kenta M.
OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54 98C1 CEFE 8AFB 6081 B062

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

e$B5WJ]$G$9!#e(B

2010/8/24 Kenta M. [email protected]:

e$B$$$C$=$N$3$H!“e(BJava e$B$N;EMM$r??;w$9$k$H$$$&$N$b$”$j$+$b$7$l$J$$!#e(B

e$B2?$N:,5r$b$J$/C;MmE*$Ke(B Java e$B$K9g$o$;$h$&$H$$$&9M$($K$O;?F1$G$-$^$;$s$7!"e(B
e$B$J$<$=$3$Ge(B Java [email protected]$1e(Be$B$,=P$F$/$k$N$+$bNI$/J,$+$j$^$;$s!#e(B

e$B:,5r$H$7$F$Oe(B 2e$B$D$"$j$^$9!#e(B

  • e$B%(%i!<$N%$%s%?!<%U%’%$%9$,??;w$G$-$k!#e(B
    SUSv3 e$B$Oe(B C [email protected]%Y!<%9$J$N$G!"!Ve(Berrno e$B$Ke(B EDOM
    [email protected]_Dj$7$D$DCM$rJV$9!We(B
    e$B$H$$$&$3$H$,$G$-$k$1$l$I!"e(BRuby [email protected]$H!Ve(BError::EDOM
    e$BNc30$rEj$2$D$DCM$re(B
    e$BJV$9!W$H$$$&$3$H$,$G$-$J$$!#e(BJava e$B$J$i$P??;w$G$-$k!#e(B
  • JRuby e$BB&$H$be(B Math e$B$N5sF0$r9g$o$;$k$d$9$/$J$k!#e(B
    e$B%W%i%C%H%U%)!<%$K$h$kF0:n$N0c$$$r2r>C$9$k$?$a$Ke(B atan2() e$B$N5sF0$,E}0le(B e$B$5$l$?$o$1$G$9$,!"$3$3$G$$$&%W%i%C%H%U%)!<%$Ke(B MRI
    e$B$N$_$J$i$:e(B JRuby e$B$be(B
    e$B4^$a$F9M$($k$H!"e(BJava e$B$H9g$o$;$?$[$&$,e(B JRuby
    e$BB&$O=u$+$k$G$7$g$&!#e(B
    JRuby e$B$NN)>l$G9M$($k$He(B Java e$B$N?t3X4X?t$He(B JRuby
    e$B$N?t3X4X?t$N7k2Le(B
    e$B$,0c$&$H:$$C$?$3$H$K$J$j$=$&$G$9$7!#e(B

e$B$H$O$$$C$F$b!“L5>r7o$Ke(B Java
e$B$K9g$o$;$h$&$H$O;W$C$F$J$/$F!“e(BSUSv3 e$B$He(B Java
e$B$N;EMM$r$D$-$”$o$;$F$+$i$I$&$9$k$+7h$a$h$&$H;W$C$F$^$7$?!#e(B
e$B$b$7$b0c$$$,$”$C$?$i!"8DJL$K9M$($h$&$+$H!#e(B

Math.atan2 e$B$O?t3X$N4X?t$G$9$+$i!"[email protected]$1?t3XE*$K9M$($?$$$G$9$7!"e(B
e$BB>[email protected]$r;29M$K$9$k$J$ie(B Java [email protected]$b8+$?$[$&$,NI$$$G$7$g$&!#e(B

Common Lisp [1] e$B$He(B Scheme (R6RS) [2] e$B$rD4$Y$F$_$k$H!"<!$N$h$&$K$J$C$F$$$^$9e(B:

Lisp e$B7O$O;d$N;kLn$+$i$O$:$l$F$$$?$N$G!“e(BCommon Lisp e$B$He(B Scheme
(R6RS)
e$B$N>pJs$O$”$j$,$?$$$G$9!#e(B

Perl e$B$de(B PHP e$B$Oe(B libm
e$B$K4][email protected]$C$?$N$G;29M$K$G$-$:!";29M$K$G$-$?$N$Oe(B
Java (*1)e$B$He(B
JavaScript(e$B87L)$K$Oe(BECMA-262)(*2)[email protected]$C$?$N$G!#e(B

*1 http://download-llnw.oracle.com/javase/6/docs/api/java/lang/Math.html
*2
http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf

e$B$`$i$?$G$9!#e(B

On 2010/08/24, at 12:32, KOSAKI Motohiro wrote:


e$B$3$N<0$+$iMh$F$$$k$h$&$G$9!#e(BWikipedia [3] e$B$K$"$ke(B atan2 e$B$Ne(B3e$B<!85%0%i%U$r8+$l$Pe(B
Scheme e$B$NDj5A$r:NMQ$9$k;v$,E,@Z$J$h$&$K46$8$^$9!#e(B

[email protected]$3&$Ge(B +0, -0, 0 e$B$N#3$D$r6hJL$G$-$k$N$G$7$?$C$1!)e(B

e$B$=$&[email protected]$o$l$F9M$($F$_$k$H$G$-$J$$$G$9$M!#e(B

e$B$H$J$k$H7k6I;d$NCf$G$O!"e(B atan2 e$B$Oe(B SUSv3
e$B$N5sF0$,NI$$$H$$$&;v$GMn$ACe$-$=$&$G$9!#e(B


Kenta M.
OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54 98C1 CEFE 8AFB 6081 B062

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

e$B5WJ]$G$9!#e(B

2010/8/24 Kenta M. [email protected]:

Ruby e$B$N<BAu$Oe(B CRuby e$B$He(B JRuby [email protected]$1$G$O$J$/$F!"e(B
IronRubye$B!"e(BRubiniuse$B!"e(BMacRuby e$B$J$IB>$K$bB8:_$7$F$$$^$9!#e(B
e$B$G$9$+$i!"e(BJRuby e$B$r;}$A=P$9$N$J$iB>$N=hM}7O$bF1Ns$K07$C$?$[$&$,NI$$$H;W$$$^$9!#e(B

e$B;d$O!"B>$N=hM}7O$N<BAu$K$D$$$FFC$K5$$K$9$kI,MW$OL5$$$H;W$C$F$$$^$9$,!#e(B

e$B$($($H!“L5>r7o$Ke(B Java
e$B$K9g$o$;$h$&$H;W$C$F$$$k$o$1$G$O$J$$$N$G!“e(BJava e$B$He(B
SUSv3 e$B$KL7=b$,$”$C$?$H$-$K8DJL$K9M$($^$7$g$&!#e(B
e$BL\E*$H$7$F$O!V%(%i!<$N%$%s%?!<%U%’%$%9$,??;w$G$-$k!W$,%a%$%s$G!”!Ve(BJRuby
e$BB&$H$be(B
Math
e$B$N5sF0$r9g$o$;$k$d$9$/$J$k!W$N$[$&$OJdB-:`NA$H$7$F=q$$$?DxEY$J$N$G!#e(B

e$B$"$H!"e(BIronRuby e$B$O$H$b$+$/!"e(BRubinius e$B$Oe(B libm
e$B$K4]Ej$2!"e(BMacRuby e$B$bB?J,4]Ej$2$Je(B
e$B$N$G!"F1Ns$K07$*$&$H$7$F$b07$($J$$$N$G$O$J$$$+$H!#e(B

e$B$`$i$?$G$9!#e(B

On 2010/08/24, at 13:44, KUBO Takehiro wrote:

  • JRuby e$BB&$H$be(B Math e$B$N5sF0$r9g$o$;$k$d$9$/$J$k!#e(B
    e$B%W%i%C%H%U%)!<%$K$h$kF0:n$N0c$$$r2r>C$9$k$?$a$Ke(B atan2() e$B$N5sF0$,E}0le(B e$B$5$l$?$o$1$G$9$,!"$3$3$G$$$&%W%i%C%H%U%)!<%$Ke(B MRI e$B$N$_$J$i$:e(B JRuby e$B$be(B
    e$B4^$a$F9M$($k$H!"e(BJava e$B$H9g$o$;$?$[$&$,e(B JRuby e$BB&$O=u$+$k$G$7$g$&!#e(B
    JRuby e$B$NN)>l$G9M$($k$He(B Java e$B$N?t3X4X?t$He(B JRuby e$B$N?t3X4X?t$N7k2Le(B
    e$B$,0c$&$H:$$C$?$3$H$K$J$j$=$&$G$9$7!#e(B

Ruby e$B$N<BAu$Oe(B CRuby e$B$He(B JRuby [email protected]$1$G$O$J$/$F!"e(B
IronRubye$B!"e(BRubiniuse$B!"e(BMacRuby e$B$J$IB>$K$bB8:_$7$F$$$^$9!#e(B
e$B$G$9$+$i!"e(BJRuby
e$B$r;}$A=P$9$N$J$iB>$N=hM}7O$bF1Ns$K07$C$?$[$&$,NI$$$H;W$$$^$9!#e(B

e$B;d$O!"B>$N=hM}7O$N<BAu$K$D$$$FFC$K5$$K$9$kI,MW$OL5$$$H;W$C$F$$$^$9$,!#e(B


Kenta M.
OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54 98C1 CEFE 8AFB 6081 B062

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

e$B$`$i$?$G$9!#e(B

e$B7k6I!"e(Batan2(±0.0, ±0.0) [email protected][email protected]$1$NBP1~$Ge(B
e$B;vB-$j$k$H9M$($FNI$$$G$9$+!)e(B > e$B5WJ]$5$se(B

e$BB>$K0U8+$,L5$1$l$P!"1sF#$5$s$Ne(B patch [ruby-dev:42097] + test
e$B$He(B rubyspec e$B$Ne(B
e$BJQ99$r%3%_%C%H$7$F$7$^$*$&$+$H;W$$$^$9!#e(B

e$B$^$D$b$H$5$s!"$h$m$7$$$G$7$g$&$+!)e(B


Kenta M.
OpenPGP FP = 1D69 ADDE 081C 9CC2 2E54 98C1 CEFE 8AFB 6081 B062

e$BK$r=q$-$^$7$?e(B!!
e$B!Xe(BRuby e$B5U0z$-%l%7%T!Ye(B
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: [email protected]
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/

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

In message “Re: [ruby-dev:42136] Re: Math::atan2(0, 0) on ruby 1.9.2”
on Thu, 26 Aug 2010 10:20:39 +0900, Kenta M. [email protected]
writes:

|e$BB>$K0U8+$,L5$1$l$P!“1sF#$5$s$Ne(B patch [ruby-dev:42097] + test e$B$He(B rubyspec e$B$Ne(B
|e$BJQ99$r%3%_%C%H$7$F$7$^$*$&$+$H;W$$$^$9!#e(B
|
|e$B$^$D$b$H$5$s!”$h$m$7$$$G$7$g$&$+!)e(B

e$B$O$$!#e(B

e$B5WJ]$G$9!#e(B

e$BJV?.CY$/$F$9$_$^$;$s!#e(B

2010/8/26 Kenta M. [email protected]:

e$B$`$i$?$G$9!#e(B

e$B7k6I!"e(Batan2(±0.0, ±0.0) [email protected][email protected]$1$NBP1~$Ge(B
e$B;vB-$j$k$H9M$($FNI$$$G$9$+!)e(B > e$B5WJ]$5$se(B
e$BB>$K0U8+$,L5$1$l$P!"1sF#$5$s$Ne(B patch [ruby-dev:42097] + test e$B$He(B rubyspec e$B$Ne(B
e$BJQ99$r%3%_%C%H$7$F$7$^$*$&$+$H;W$$$^$9!#e(B

atan2(±0.0, ±0.0) e$B$K4X$7$F$O1sF#[email protected]$G0[[email protected]$"$j$^$;$s!#e(B
e$B=5Kv$Ke(B atan2()
e$B0J30$N?t3X4X?t$b$R$H$H$*$jD4$Y$F$$k$N$G!"$J$K$+e(B
e$BDs0F$9$k$+$b$7$l$^$;$s$,!":#[email protected]$N$
$G$9!#e(B

e$B$"$H!"e(BJava e$B$&$s$L$s$O!"e(BMath
e$B0J2<[email protected]$C$?e(B
e$B$o$1$G$9$,!"E12s$7$^$9!#e(BRuby e$B$Ne(B Math
e$B$OCM$K$h$C$F$ONc30$r=P$9$K$Ne(B
e$BBP$7$F!"e(BJava e$B$Ne(B Math
e$B$ONc30$r$^$C$?$/=P$5$J$$$N$G!“e(B1.8.x, 1.9.1e$B$H$Ne(B
[email protected]$NLdBj$G$I$C$A$K$7$mBLL$G$7$g$&!#e(B
e$B:G=i$Ke(B Java
[email protected]$7$?%a!<%k$N<gL\E*$O!V!J$-$A$s$HD4$Y$k;~4V$,$H$le(B
e$B$F$J$$$N$G!K:#=5Kv$K$G$bD4$Y$F$_$^[email protected]$C$?$N$G$9$,!”[email protected]$+$i$H$$$C$Fe(B
e$B$$$m$$$m>JN,$7$9$.$G$7$?!#e(Bm(__)m

e$B$A$J$_$K!":G=i$N%a!<%k$Ne(B

e$B:G6a$N%7%9%F%`$G$Oe(B atan2(0, 0) e$B$NLa$jCM$,<BAu0MB8$G$O$J$/$J$C$Fe(B
e$B$-$F$*$j!“e(B
e$B$NItJ,$O40A4$K4V0c$$$G$7$?!#e(Bm(__)m
SUSv3 e$B$G$Ne(B atan2(±0, ±0) e$B$N5sF0$Oe(B The functionality
described
is optional. e$B$HCm5-$5$l$F$$$k$N$G!”<BAu0MB8$J$N$Oe(B SUSv3
e$B$G$bF1$8e(B
e$B$G$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs