複素数リテラルについて

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

2009/07/23 1:47 e$B$Ke(B Tadayoshi F.[email protected]
e$B$5$s$O=q$-$^$7$?e(B:

e$BMW$9$k$K!"%j%F%i%k$8$cJ#AG?t$N;H$$>!<j$O$"$^$j$"$,$i$J$$$s$8$c$J$$$+!"e(B
e$B$HJ9$$$F$$$^$9!#e(B

1+n*1i e$B$H=q$/$/$i$$$J$i!"e(BMath::PI e$B$de(B Math::E e$B$K$J$i$C$Fe(B Math::I e$B$rF~$l!"e(B

1 + n * Math::I

e$B$H$7$?J}$,FI$$d$9$$$H;W$$$^$7$?!#e(Binclude Math e$B$9$l$Pe(B I e$B$G:Q$$^$9$7!#e(B

e$B$=$l$O9%$-$K$9$l$P$$$$$H;W$$$^$9!#0l1~e(B Complex::I e$B$,$"$j$^$9$1$I$M!#e(B

e$B$U$J$P$5$s$Oe(B 1+n*1i e$B$NJ}$,FI$_$d$9$$e(B or
e$B=q$-$d$9$$$H;W$o$l$ke(B
e$B$s$G$7$g$&$+!#e(B

e$B$b$7%j%F%i%k$rF~$l$F$bJ#AG?t$,Bg$7$FJXMx$K$J$i$J$$$N$G$"$l$P!"e(B
e$BJ8K!$r3HD%$9$k0UL#$O$J$$$h$&$K;W$$$^$9!#e(B

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

In message Re: [ruby-dev:38846] Re: e$BJ#AG?t%j%F%i%k$K$D$$$Fe(B
on Wed, 22 Jul 2009 17:30:34 +0900, take_tk [email protected]
writes:

|e$B!v!!!Ve(B2ie$B!W%j%F%i%k$,$G$-$k$J$i!Ve(B20090722Te$B!W%j%F%i%k$bM_$7$$!&!&!#e(B

e$B$[$7$$$N$G$"$l$P!"$=$l$O$=$l$GJL$KOC$r$"$2$F$/[email protected]$5$$!#:.$<$ke(B
e$B$H$m$/$J$3$H$O$J$$$s$G!#e(B

e$B$U$J$P$5$s$Oe(B 1+n*1i e$B$NJ}$,FI$_$d$9$$e(B or e$B=q$-$d$9$$$H;W$o$l$ke(B
e$B$s$G$7$g$&$+!#e(B

e$B$=$l$O>l9g$K$b$h$k$G$7$g$&$M!#$?$V$s!"e(BComplex(1, n)
e$B$H=q$/$3$H$,B?$$$He(B
e$B;W$$$^$9!#e(B

1 + n * Complex::I e$B$de(B Complex(1, n) [email protected]$+$i!"e(B1+3i
e$B$N$h$&$JI=8=e(B
e$B$O0UL#$,$J$$$H$b;W$$$^$;$s!#e(B

e$B$b$7%j%F%i%k$rF~$l$F$bJ#AG?t$,Bg$7$FJXMx$K$J$i$J$$$N$G$"$l$P!"e(B
e$BJ8K!$r3HD%$9$k0UL#$O$J$$$h$&$K;W$$$^$9!#e(B

e$B$=$l$O$=$&$G$7$g$&!#[email protected]!"$^$D$b$H$5$s$,Ds0F$7$F$$$k$N$O!"$[$H$s$I;z6ge(B
e$B%l%Y%[email protected]$G!"1sF#$5$s$,Ds0F$7$F$$$k$N$O!"9=J8%l%Y%k$G$$$8$i$J$$$HBLe(B
e$BL$J$h$&$K;W$$$^$9!#$=$7$F$=$l$,e(B ruby
e$B$NJ8K!$NCf$GB8:_2DG=$J$N$+$I$&$+!"e(B
e$B$A$g$C$HH=$i$J$$$s$G$9$,!#e(B

e$B$"$H![email protected]$&$H!$^$D$b$H$5$s$NDs0F$r<u$1F~$l$J$1$l$P$J$i$J$$$He(B
e$B<gD%$7$F$$$k$o$1$G$O$"$j$^$;$s!#e(B

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

In message Re: [ruby-dev:38873] Re: e$BJ#AG?t%j%F%i%k$K$D$$$Fe(B
on Thu, 23 Jul 2009 02:27:33 +0900, Tadayoshi F.
[email protected] writes:

|> e$B$b$7%j%F%i%k$rF~$l$F$bJ#AG?t$,Bg$7$FJXMx$K$J$i$J$$$N$G$"$l$P!e(B
|> e$BJ8K!$r3HD%$9$k0UL#$O$J$$$h$&$K;W$$$^$9!#e(B
|
|e$B$=$l$O$=$&$G$7$g$&!#[email protected]!$^$D$b$H$5$s$,Ds0F$7$F$$$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

e$B9M$(D>$7$F$_$k$H!"7k6I;d$,7y$J$N$Oe(B 1+2i e$B$He(B Complex(1, n) e$B$N8+$?L$,e(B
e$B0c$$$9$.$k$3$He(B (+ e$B=q$-49$($,LLE]$/$5$$$3$He(B) [email protected]$H;W$$;j$j$^$7$?!#e(B

e$B>-MhE*$K$Oe(B Complex#inspect e$B$de(B #to_s e$B$,e(B (1 + 2i)
e$B$H$$$&$h$&$JI=8=$rJV$9e(B
e$B$h$&$K$J$je(B[ruby-dev:38852] e$B!"e(BComplex(-5, 10)
e$B$H$$$&I=8=$OFC<l$J>l9g$K$7e(B
e$B$+;H$o$l$J$/$J$k$h$&$J5$$,$7$^$9!#e(B

p (1+2i)*(3+4i) #=> (-5 + 10i)

e$B$H$$$&$h$&$KJV$l$P![email protected]$G$b$=$N0UL#$,J,$+$k$G$7$g$&!#AG?ME*$K$O!!J:Ge(B
[email protected]$1$G$9$,!Ke(BComplex(-5,10)
e$B$H$$$&Ez$($r8+$F!"$.$g$C$H$7$F$7$^$$$^$7$?!#e(B
e$B7W;;$NEz$($,e(B Integer(1) e$B$H$+e(B Float(1.2)
e$B$J$I$HI=8=$5$l$?$i$.$g$C$H$7$F$7e(B
e$B$^$&$G$7$g$&!#e(B

e$B!V?t;z$NItJ,$rJQ?t$KJQ99$9$k$N$G$"$l$P!"!Ve(B.e$B!W!J%I%C%H!K$rF~$l$F%a%=%C%Ie(B
e$B8F$S=P$7$KJQ99$9$kI,MW$,$"$j$^$9!W$HCm0U=q$-$7$F$*$1$P!"e(B

(1+2i)*(3+4i)

e$B$re(B

a=1 ; b=2 ; c=3 ; d=4
p (a+b.i)*(c+d.i) #=> (-5 + 10i)

[email protected]$7!"$H$F$bJ,$+$j$d$9$$$H;W$$$^$9!#e(B

take_tk = kumagai hidetake

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

2009/07/23 4:43 e$B$Ke(B take_tk[email protected]
e$B$5$s$O=q$-$^$7$?e(B:

[email protected]$7!"$H$F$bJ,$+$j$d$9$$$H;W$$$^$9!#e(B
Numeric#i
e$B$b$"$o$;$FF~$k$3$H$,3N<B$J$i!"$=$l$G$b$$$$$+$J$H;W$$$^$7$?!#e(B
[email protected]!"$=$l$J$i:G=i$+$ie(B

(1+2.i)*(3+4.i)

e$B$H=q$/$3$H$K$9$l$P!"$=$l$[$I=q$-$K$/$/$b$J$$$7!"JQ$J%k!<%k$,8:$C$Fe(B
e$B$h$jNI$$$h$&$J5$$b$7$^$9!#e(B

e$B5u?t$h$j%f!<%6$NB?$=$&$Je(B pi e$B$de(B e e$B$Oe(B 2 * Math::PI
e$B$de(B 2 * Math::E e$B$He(B
e$B$J$C$F$$$k$N$K!e(B2i
[email protected]$1?t<0$_$?$$$JI=5-$r5v$9M}M3$O$$k$N$G$7$g$&$+!#e(B

2xxx e$B$re(B (2 * Math::XXX) e$B$Ne(B syntax sugar

e$B$H$9$k$H$+$I$&$+$J!D!D!#e(B

e$B$"$-$i$G$9e(B

p (1+2i)*(3+4i) #=> (-5 + 10i)

e$B$H$$$&$h$&$KJV$l$P!"[email protected]$G$b$=$N0UL#$,J,$+$k$G$7$g$&!#e(B

e$B$9$_$^$;$s!"=q$3$&$+G:[email protected]$N$G$9$,e(B
e$B5u?t$C$F0lHLE*$K$O9b9;#2G/$0$i$$$+$i$8$c$J$$$G$7$g$&$+!)e(B

e$BK\Bj$H$O4X78$J$$$N$G%9%k!<[email protected]$1$l$P$H;W$$$^$9e(B

e$B$"$-$ie(B

On 7/23/09 9:43 AM, Yusuke ENDOH wrote:

e$B5u?t$h$j%f!<%6$NB?$=$&$Je(B pi e$B$de(B e e$B$Oe(B 2 * Math::PI e$B$de(B 2 * Math::E e$B$He(B
e$B$J$C$F$$$k$N$K!e(B2i [email protected]$1?t<0$_$?$$$JI=5-$r5v$9M}M3$O$$k$N$G$7$g$&$+!#e(B

2xxx e$B$re(B (2 * Math::XXX) e$B$Ne(B syntax sugar e$B$H$9$k$H$+$I$&$+$J!D!D!#e(B

e$B5u?t%j%F%i%[email protected]$H;W$&$H$=$&$J$C$F$7$^$&$s$G$9$h$M!#e(B
e$B;d$N463P$G$OJ#AG?t$OJ#AG?t$H$$$&$b$N$G$"$C$F!"$=$l$,4pDle(B<1,
i>e$B$r$H$k$N$Oe(B
[email protected]$H;W$&$s$G$9$M!#FbIt<BAu$H$$$&$+!#e(B

[email protected]$+$i!"e(B-2 e$B$,e(B [email protected] e$B$G$O$J$$$N$HF1$8M}6~$Ge(B 1+2i
e$B$,e(B 1.+(Complex(0, 2)) e$B$Ge(B
e$B$O$J$/!e(BComplex(1, 2)
e$B$H$$$&$3$H$K$7$J$$$H!$=$N<o$N0cOB46$r$L$0$($J$$$He(B
e$B;W$$$^$9!#e(B

e$B$=$&$7$?$H$7$F$b!V$G$b%/%)!<%?%K%%s$O%j%F%i%k$O$$m$+AH$9~$$G$9$i$J$$e(B
e$B$>!W$H$$$&LdBj$OH/@8$9$k$s$G$9$,!"$=$l$O9)3X>e$NMxMQIQEY$N:[email protected]~$r0z$/$He(B
e$B$$$&$3$H$G$9$M!#e(B

e$B$O$8$a$^$7$F!#HuB<$H$$$$$^$9!#e(B

2xxx e$B$re(B (2 * Math::XXX) e$B$Ne(B syntax sugar e$B$H$9$k$H$+$I$&$+$J!D!D!#e(B

Ruby e$B$H$O4X78$J$$OC$G62=L$G$9$,!"e(BC++0x e$B$Ne(B current draft
e$B$K$Oe(B
User-defined literals e$B$J$k$b$N$,Dj5A$5$l$F$$$k$h$&$G$9!#e(B

http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2914.pdf (see
section 2.14.8)
http://www.open-std.org/JTC1/SC22/WG21

e$BNc$($Pe(B
long double operator""km(long double);
e$B$N$h$&$KDj5A$7$F$*$$$F!e(B12.5km e$B$H$+=q$/$He(B
operator"km(12.5L) [email protected](B
e$B$3$H$K$J$j$^$9!#e(B

Ruby e$B$G$b!"$3$l$H;w$?$h$&$JJ*$rF3F~$7$F!"e(B
2i # => 2.literal_i
e$B$H$9$k$H$+$O$I$&$G$7$g$&$+!)$3$l$r;H$($P!"e(BRational e$B$be(B
3/2r # => 3 / 2.literal_r => 3 / Rational(2,1) => Rational(3,2)
e$B$H=q$1$^$9!#e(B

e$B8e<T$,DjCe$9$k$He(B 3/2i == -3i/2

e$B$G%O%^$k?M$,B3=P$7$=$&$G$9$,!De(B

e$B$=$&$7$?$H$7$F$b!V$G$b%/%)!<%?%K%%s$O%j%F%i%k$O$$m$+AH$9~$$G$9$i$J$$e(B
e$B$>!W$H$$$&LdBj$OH/@8$9$k$s$G$9$,!"$=$l$O9)3X>e$NMxMQIQEY$N:[email protected]~$r0z$/$He(B
e$B$$$&$3$H$G$9$M!#e(B
e$B;M85?t$O!D!"$I$&$7$^$7$g$&$+!"e(Bi e$B$,5u?t$H$+$V$j$^$9$M!#e(B

e$B$A$g$C$H$d$j$9$.$J46$O$"$j$^$9$,!"EEBnMQES$G$OJXMx$+$H!#e(B

Quanty e$B$de(B NumRu::Units e$B$"$?$j$HAH$_9g$o$;$k$H$+!#e(B

[email protected]!"%i%$%V%i%j$G9%$->!<j$K%j%F%i%k$rDj5A$5$l$F$7$^$&$HGKC>$7$=$&$G$9$M!#e(B
Mix-in
e$B$H$7$FDj5A$7$F$*$$$F!";H$$$?$1$l$P%f!<%6B&$G$d$C$F$b$i$&$H$7$F$b!"e(B
e$B0lEYe(B mix-in
e$B$5$l$F$7$^$&$HA4BN$K1F6A$rM?$($F$7$^$$$^$9$7$M!D!#e(B

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

2009/07/24 1:49 e$B$Ke(B Takahiro HIMURA[email protected]
e$B$5$s$O=q$-$^$7$?e(B:

e$B$O$8$a$^$7$F!#HuB<$H$$$$$^$9!#e(B

2xxx e$B$re(B (2 * Math::XXX) e$B$Ne(B syntax sugar e$B$H$9$k$H$+$I$&$+$J!D!D!#e(B

Ruby e$B$H$O4X78$J$$OC$G62=L$G$9$,!"e(BC++0x e$B$Ne(B current draft e$B$K$Oe(B
User-defined literals e$B$J$k$b$N$,Dj5A$5$l$F$$$k$h$&$G$9!#e(B

IRC e$B$GOCBj$K$J$C$F$^$7$?!#8D?ME*$K$O$H$F$bLLGr$$$H;W$$$^$9!#e(B

Ruby e$B$G$b!"$3$l$H;w$?$h$&$JJ*$rF3F~$7$F!"e(B
2i # => 2.literal_i
e$B$H$9$k$H$+$O$I$&$G$7$g$&$+!)$3$l$r;H$($P!"e(BRational e$B$be(B
3/2r # => 3 / 2.literal_r => 3 / Rational(2,1) => Rational(3,2)
e$B$H=q$1$^$9!#e(B

3ri/2 e$B$H=q$1$J$$$N$,6L$K`l$G$9$h$M!#e(B

e$B$I$&$;$J$ie(B

5C3 #=> 5.literal_C(3) #=> 20
5P3 #=> 5.literal_P(3) #=> 60

e$B$_$?$$$J$3$H$b=PMh$k$HLLGr$$$G$9$M!#e(B

[email protected]!"%i%$%V%i%j$G9%$->!<j$K%j%F%i%k$rDj5A$5$l$F$7$^$&$HGKC>$7$=$&$G$9$M!#e(B

e$B$=$&;W$$$^$9!#$J$N$G!F3F~$9$k$H$7$F$be(B classbox
e$B$_$?$$$J$b$N$Ge(B
e$B1F6AHO0O$r9J$l$k$h$&$K$J$C$F$+$i$NJ}$,$$$$$+$J!$H$$$&0U8+$,e(B
e$B=P$F$^$7$?!#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