複素数リテラルについて

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

RubyKaigie$B$N%-!<%N!<%H$G$bOC$7$^$7$?$,!"J#AG?t%j%F%i%k$r<B8=e(B
e$B$9$k%Q%C%A$r=q$-$^$7$?!#$3$l$rEv$F$k$H!"e(B

2i
2.0i

e$B$N$h$&$JI=8=$,2DG=$K$J$j$^$9!#$5$F!"$3$l$r<h$j9~$b$&$+$I$&$+e(B
e$B9M$($F$$$k$N$G$9$,!"8!F$$r<[email protected]$1$kJ}$O$$$i$C$7$c$$e(B
e$B$^$9$+!)e(B

e$B8!F$$9$Y$-$3$He(B

diff --git a/parse.y b/parse.y
index d311e133630c60 100644
a/parse.y
+++ b/parse.y
@@ -655,14 +655,14 @@ static void token_info_pop(struct parser_params*,
const char *token);
keyword__ENCODING__

%token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
-%token tINTEGER tFLOAT tSTRING_CONTENT tCHAR
+%token tINTEGER tFLOAT tCOMPLEX tSTRING_CONTENT tCHAR
%token tNTH_REF tBACK_REF
%token tREGEXP_END

%type singleton strings string string1 xstring regexp
%type string_contents xstring_contents string_content
%type words qwords word_list qword_list word
-%type literal numeric dsym cpath
+%type literal numeric num_lit dsym cpath
%type bodystmt compstmt stmts stmt expr arg primary command
command_call method_call
%type expr_value arg_value primary_value
%type if_tail opt_else case_body cases opt_rescue exc_list
exc_var opt_ensure
@@ -2063,16 +2063,7 @@ arg : lhs = arg
$$ = dispatch3(binary, $1, ripper_intern("**"), $3);
%*/
}

  • | tUMINUS_NUM tINTEGER tPOW arg
  •    {
    
  •    /*%%%*/
    
  •  $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0);
    
  •    /*%
    
  •  $$ = dispatch3(binary, $2, ripper_intern("**"), $4);
    
  •  $$ = dispatch2(unary, ripper_intern("[email protected]"), $$);
    
  •    %*/
    
  •    }
    
  • | tUMINUS_NUM tFLOAT tPOW arg
  • | tUMINUS_NUM num_lit tPOW arg
    {
    /%%%/
    $$ = NEW_CALL(call_bin_op($2, tPOW, $4), tUMINUS, 0);
    @@ -4092,17 +4083,13 @@ dsym : tSYMBEG xstring_contents tSTRING_END
    }
    ;

-numeric : tINTEGER
+num_lit : tINTEGER
| tFLOAT

  • | tUMINUS_NUM tINTEGER %prec tLOWEST
  •    {
    
  •    /*%%%*/
    
  •  $$ = negate_lit($2);
    
  •    /*%
    
  •  $$ = dispatch2(unary, ripper_intern("[email protected]"), $2);
    
  •    %*/
    
  •    }
    
  • | tUMINUS_NUM tFLOAT %prec tLOWEST
  • | tCOMPLEX
  • ;

+numeric : num_lit

  • | tUMINUS_NUM num_lit %prec tLOWEST
    {
    /%%%/
    $$ = negate_lit($2);
    @@ -6858,9 +6845,9 @@ parser_yylex(struct parser_params *parser)
    case 0: case 1: case 2: case 3: case 4:
    case 5: case 6: case 7: case 8: case 9:
    {
  •  int is_float, seen_point, seen_e, nondigit;
    
  •  int is_float, seen_point, seen_e, nondigit, is_complex;
    
  •  is_float = seen_point = seen_e = nondigit = 0;
    
  •  is_float = seen_point = seen_e = nondigit = is_complex = 0;
     lex_state = EXPR_END;
     newtok();
     if (c == '-' || c == '+') {
    

@@ -7046,6 +7033,10 @@ parser_yylex(struct parser_params *parser)
nondigit = c;
break;

  •  case 'i':
    
  •    is_complex++;
    
  •    goto decode_complex;
    
  •  default:
       goto decode_num;
    

    }
    @@ -7054,6 +7045,7 @@ parser_yylex(struct parser_params *parser)

    decode_num:
    pushback;

  • decode_complex:
    tokfix();
    if (nondigit) {
    char tmp[30];
    @@ -7067,9 +7059,18 @@ parser_yylex(struct parser_params *parser)
    rb_warningS(Float %s out of range, tok());
    errno = 0;
    }

  • if (is_complex) {

  •    set_yylval_literal(rb_complex_new(INT2FIX(0), DBL2NUM(d)));
    
  •    return tCOMPLEX;
    
  • }
    set_yylval_literal(DBL2NUM(d));
    return tFLOAT;
    }

  •  if (is_complex) {
    
  • set_yylval_literal(rb_complex_new(INT2FIX(0),

  •          rb_cstr_to_inum(tok(), 10, Qfalse)));
    
  • return tCOMPLEX;

  •  }
           set_yylval_literal(rb_cstr_to_inum(tok(), 10, Qfalse));
     return tINTEGER;
    

    }
    @@ -8677,6 +8678,7 @@ negate_lit(NODE *node)
    node->nd_lit = LONG2FIX(-FIX2LONG(node->nd_lit));
    break;
    case T_BIGNUM:

  •  case T_COMPLEX:
    

    node->nd_lit = rb_funcall(node->nd_lit,tUMINUS,0,0);
    break;
    case T_FLOAT:

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

e$B$9$&$,$/$O6l<j$J$N$G$"$s$^$jLr$K$ON)$F$J$$$N$G$9$,!"e(B

In message [ruby-dev:38843] e$BJ#AG?t%j%F%i%k$K$D$$$Fe(B
on Jul.22,2009 07:08:24, [email protected] wrote:

e$BFC$KLdBj$,$J$$$J$i!"e(Bie$B$He(Bje$B$NN>J}$r5v$9$N$,$$$$$N$G$O$J$$$G$7$ge(B
e$B$&$+!#e(B

  • e$BJ#AG?t2=$9$k%a%=%C%Ie(BNumeric#ie$B$OMW$i$J$$$+e(B
  • e$BMW$k$J$i!"5u?te(B.ie$B$NCM$O2?$+!)e(B e$BJ#AG?te(B.ie$B$NCM$O!)e(B

Numeric#ie$B$,I,MW$+$I$&$+$K$D$$$F$OFC$K0U8+$O$J$$$G$9$,!"$=$l$Oe(B
selfe$B$K5u?tC10L$r3]$1$k$H$$$&A`:n$K$J$k$N$G$7$g$&!#e(B
e$B$D$^$j!"e(BNumeric#ie$B$N<BAu$Oe(BComplex(0,
self)e$BAjEv$K$J$k$N$G$O$J$$e(B
e$B$+$H;W$$$^$9!#e(B

e$B$=$l$G$O!#e(B

e$B$?$1e(B(tk)e$B$G$9e(B

RubyKaigie$B$N%-!<%N!<%H$G$bOC$7$^$7$?$,!"J#AG?t%j%F%i%k$r<B8=e(B
e$B$9$k%Q%C%A$r=q$-$^$7$?!#$3$l$rEv$F$k$H!"e(B

2i
2.0i

e$BJ#AG?t$O!Ve([email protected]$m$&$+$i!"!Ve([email protected]$1$J$i5u?t%j%F%i%k$M!#e(B

  • e$BJ#AG?t2=$9$k%a%=%C%Ie(BNumeric#ie$B$OMW$i$J$$$+e(B
  • e$BMW$k$J$i!"5u?te(B.ie$B$NCM$O2?$+!)e(B e$BJ#AG?te(B.ie$B$NCM$O!)e(B

e$B!Ve(B2ie$B!W$H$$$&$N$O!Ve(B2*ie$B!W$N>JN,7A$G$O$J$+$C$?$C$1!)e(B

R:\USR>ruby -rcomplex -e i=Complex(0,1); p (3+2*i)*i
Complex(-2, 3)

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

Take_tk = KUMAGAI Hidetake
e$B$?$1e(B(tk)e$B!a7C+=(Ipe(B

2.0 e$B$G$O!e(B1/2 #=> (1/2) e$B$de(B 3i #=> (0+3i)
e$B$J$I$H=q$1$h$&$K$G$-$?$i$$$$$He(B
e$B8D?ME*$K4|BT$7$F$$$^$9!#$=$3$G!>/$7HyL/$J$N$Oe(B scheme
e$B$N$h$&$J463P$Ge(B
1/3i e$B$H=q$/$H!e(B1/3
e$B$b%j%F%i%k$G$$l$PLdBj$J$$$G$9$,!"$=$&$G$J$$$H!"7k2Le(B
e$B$,e(B (-1/3)i
e$B$H$J$C$F$7$^$$$^$9!#;EJ}$,$,$J$$$+$b$7$l$^$;$s$,!#e(B

e$BM-M}?t$r4^$a!"e(B2.0
e$B$G$I$&$$$&$b$N$rDs6!$7$?$$$+H=$i$J$$$H!"J#AG?t%j%F%ie(B
e$B%ke(B (e$B5u?t%j%F%i%ke(B?)
e$B$r$I$&[email protected]$($J$$$h$&$J5$$,$7$^$9!#e(B

python e$B$,2?8Ne(B j e$B$+$OCN$j$^$;$s$,!"e(Boctave e$B$J$I$G$be(B j
e$B$H=q$$$F$$$$$_$?$$!#e(B
e$B9)3X$NN.57$H$$$&$3$H$J$N$+$b$7$l$^$;$s!#e(BJ (apl e$B$N8e7Q$Ne(B)
e$B$G$O!"J#AG?t$re(B
1j3 e$B$N$h$&$K=q$1$k$h$&$G$9!#e(B

e$B$A$J$_$K!"0JA0$K:n$C$?e(B nuby
e$B$G$O!"e(Bie$B!"e(Bje$B!"e(BIe$B!"e(BJ
e$B$$$E$l$G$b$G$b$h$$$H$7$F$$$^$7$?!#e(B

  • e$BJ#AG?t2=$9$k%a%=%C%Ie(BNumeric#ie$B$OMW$i$J$$$+e(B

1.9.1 e$B$N3+H/CJ3,$G5Q2<$5$l$F$$$^$9!#e(B

e$B%S%k%I$G$-$J$+$C$?$N$G!"%Q%C%A$NFbMF$O$o$+$j$^$;$s$G$7$?$7!"%-!<%N!<%He(B
e$B$bJ9$$$F$J$$$N$GH=$i$J$$$G$9$,!e(B2.0
[email protected]$r;O$a$h$&$H$$$&$3$H$Je(B
e$B$N$G$7$g$&$+!#[email protected]$H$O$$$(!$+$J$j4X?4$,Dc$$$h$&$K;We(B
e$B$($?$N$K!"$J$<$3$N%j%F%i%k$NOC$,:#EbFM$K=P$F$-$?$N$+!"IT;W5D$J46$8$G$9!#e(B

[email protected]>/$7?t3X$r$7$F$$$?$3$H$,$"$j$^$9!";VB<$H$$$$$^$9!#e(B

In message [ruby-dev:38845] Re: e$BJ#AG?t%j%F%i%k$K$D$$$Fe(B,
[email protected],
U.Nakamura wrote

on Jul.22,2009 07:08:24, [email protected] wrote:

  • ie$B$G$$$$$N$+!#e(BPythone$B$O$J$<$+e([email protected]$,!#e(B
    Python e$B$N;v$OJ,$+$j$^$;$s$,!e(B
    e$B3N$+$K5u?tC10L$N5-9f$K!Ve(Bje$B!W$r;H$&$h$&$JN)>l$b$$j$^$9!#e(B
    e$BEE5$7O$J$I!4{$KJL$N0UL#$GJQ?tL>$J$I$K!Ve(Bie$B!W$r;H$&=,47$N$$k>l9g$Ke(B
    e$B5u?tC10L$H$7$F!Ve(Bje$B!W$r:NMQ$9$k%1!<%9$J$I$G$9!#e(B
    e$B0lJ}$b$H$b$He(B Imaginary number e$B$Ne(B unit (imaginary unit)
    e$B$+$i$/$k!Ve(Bie$B!We(B
    e$B$H$$$&J8;z$NJ}$,[email protected]$,9b$$$N$G$d$O$j!Ve(Bie$B!W$NJ}$,NI$$$H;W$$$^$9!#e(B

e$BFC$KLdBj$,$J$$$J$i!e(Bie$B$He(Bje$B$NN>J}$r5v$9$N$,$$$$$N$G$O$J$$$G$7$ge(B
e$B$&$+!#e(B
e$B?t3X$NJ}$G$O$5$i$K;M85?t$H$$$&$N$,$$j$^$9!#e(B
e$BJ#AG?t$N!VJ#AG!W$GFs$D$N$H$3$m$,;M$D$K$J$C$F$k$b$N$G$9!#e(B
e$B$=$N;0$D$N5u?tC10L$K$O!Ve(Bie$B!W!Ve(Bje$B!W!Ve(Bke$B!W$r;H$&$N$,0lHLE*[email protected]$C$?$j$7$^$9!#e(B
e$B$=$A$i$K8m2r$5$l$k;v$r;W$&$H!Ve(Bie$B$He(Bje$B$NN>J}!W$H$$$&$N$OI]$$$G$9!#e(B

e$B!Ve(Bie$B!We(B([email protected]$1e(B)e$B$,NI$$$H;W$$$^$9!#e(B

  • e$BJ#AG?t2=$9$k%a%=%C%Ie(BNumeric#ie$B$OMW$i$J$$$+e(B
  • e$BMW$k$J$i!5u?te(B.ie$B$NCM$O2?$+!)e(B
    e$BJ#AG?te(B.ie$B$NCM$O!)e(B
    Numeric#ie$B$,I,MW$+$I$&$+$K$D$$$F$OFC$K0U8+$O$J$$$G$9$,!$=$l$Oe(B
    selfe$B$K5u?tC10L$r3]$1$k$H$$$&A`:n$K$J$k$N$G$7$g$&!#e(B
    e$B$D$^$j!"e(BNumeric#ie$B$N<BAu$Oe(BComplex(0,
    self)e$BAjEv$K$J$k$N$G$O$J$$e(B
    e$B$+$H;W$$$^$9!#e(B
    2.0.i e$B$H$+!"e(B(3 + 2.0i).i e$B$,$I$&[email protected]$&;v$G$9$M!#e(B
    e$BCM$N8uJd$r9M$($F8+$^$9!#e(B

(1) e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$N$+$I$&$+e(B(e$BBg$-$JI,[email protected]$O46$8$J$$$G$9e(B)
e$BLB$&;v$^$G9M$($k$H!$=$b$=$be(B Numeric#i
e$B<+BN$,MW$i$J$$$N$+$b$7$l$^$;$s!#e(B

e$B!Ve(B2.0.ie$B!W$,$J$/!3]$1;;e(B(e$B%a%=%C%Ie(B)e$B$G=q$/;v$K$J$C$F!e(B
e$B$=$N;~$OI,$:!Ve(B2.0 *
Complex::Ie$B!W$H=q$+$J$$$H$$$1$J$$$J$i$A$g$C$HHQ$o$7$$e(B
e$B$G$9$,!>e$K5s$2$?$h$&$K!Ve(B2.0*1ie$B!W$H=q$1$k$N$G!$=$l$GNI$$$+$J$"$H;W$$$^$9!#e(B
-------------------------------------------------------+e$B0J>ee(B
2009/7/22

e$B;VB<90G7e(B mailto: [email protected]

e$BLg304A$G?=$7Lu$J$$$N$G$9$,!e(B
e$B?t<0$H$7$F8+$d$9$$$3$H$H!%=!<%9>[email protected]$&$3$H$O>/$70c$&5$$,$7$^$9!#e(B

e$B?t<0$H$7$F8+$d$9$$$H$7$F$b!"%=!<%9%3!<%I$N9=J8$K?t<0$N9=J8$rKd$a9~$`$N$O!"%=!<%9%3!<%[email protected]$o$l$k$HHyL/$J5$$,$7$^$9!#e(B
e$B6qBNE*$K$O!"?t<0$r%9%3!<%W$KG<$a$k%9%3!<%W$Ge(Bie$B$,JQ?t$H$7$F;HMQ$5$l$F$$$?>l9g$J$I$G$9!#e(B

e$B$"$k<o!"[email protected]$&!Ve(Bie$B!W$OMMAj$G$"$k$N$G!MMAj$r$$i$o$91i;;;R$rF~$l$F$O$I$&$G$7$g$&!#e(B
e$BNc$($P!"e(B1+3#i e$B$N$h$&$J!#e(B
[email protected]!"e(Bi*ie$B$r5vMF$9$k>e$G!e(Bie$B$r?tCM$H$7$F07$&$Y$-$G$$k$J$i$P![email protected]$rE}0l$9$k0UL#$G!!Ve(Bie$B!W$=$N$b$N$,M=Ls8l$b$7$/$OAH$_9~$_4X?tL>$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,$1$k$Y$-!:.$<$k$J$i$P$=$l$J$j$N<1JL;R$rIU$1$?J}$,NI$$$H;W$&$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

e$B?t<[email protected]$H$$$&$N$,$I$&$$$&$b$N$+$o$+$i$J$$$G$9$,!"e(Bscheme
e$B$de(B python e$B$Oe(B
e$B?t<[email protected]$G!"e(Bruby e$B$O0c$&$H$$$&$3$H$J$s$G$7$g$&$+!#e(B

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

e$B?t<0$H$7$F8+$d$9$$$3$H$H!"%=!<%9>[email protected]$&$3$H$O>/$70c$&5$$,$7$^$9!#e(B
(e$BCfN,e(B)
e$B?t<[email protected]$H!e([email protected]$OJ,$1$k$Y$-!:.$<$k$J$i$P$=$l$J$j$N<1JL;R$rIU$1$?J}$,NI$$$H;W$&$N$G$9$,!"$I$&$G$7$g$&$+!#e(B

e$B?t<[email protected]$H$$$&$N$,$I$&$$$&$b$N$+$o$+$i$J$$$G$9$,!"e(Bscheme e$B$de(B python e$B$Oe(B
e$B?t<[email protected]$G!"e(Bruby e$B$O0c$&$H$$$&$3$H$J$s$G$7$g$&$+!#e(B

e$B$/[email protected]$i$J$$%l%9$K!"%l%9$rD:$$$F62=L$G$9!#e(B
[email protected]$&$H!e(B
e$B?t<0$G$O!!Ve(Bwx+y=ze$B!W$H$$$&<0$O$"$C$F$b!"!Ve(Bwx+yx=ze$B!W!Je(Byxe$B$Ne(Bxe$B$Oe(Bwxe$B$Ne(Bxe$B$H$O0UL#$,0[$J$k!K$H$$$&<[email protected]$&$3$H$G$9!#e(B
[email protected]!Ds0F$N!Ve(Bie$B!W$,5vMF$5$l$k$H!$=$N$h$&$J<0$,e(Brubye$B$N%=!<%9%3!<%I>e=P8=$9$k5vMF$r;:$s$G$7$^$&5$$,$7$^$9!#e(B

e$B:G6a!"e(Brubye$B$,JXMx$K$J$C$F$$$/$N$OJ,$+$C$F$$$k$N$G$9$,!"e(B
e$B;H$&$K$OJ#;(!J9=J8$H$OP*N%$7$?:nK!$N$h$&$JCN$k$3$H$,A}$($k!K$K$J$C$F$$$C$F$$$k$h$&$Ge(B
e$B$=$l$r4mW|$7$FLg304A$J$,$i$K?=$7>e$2$5$;$FD:$-$^$7$?!#e(B

e$B$I$3$+$NC/$+$,[email protected]$C$F$$$?$N$G$9$,!"!V%=%U%H%&%%"$O!":G=E[email protected]$rDI5a$9$k$"$^$j!";H$($J$$$0$i$$$I$&$7$h$&$b$J$/J#;([email protected]$&[email protected]$r;W$$5/$3$7$^$9!#e(B

e$B85$,;[email protected][email protected]$r4mW|[email protected]$$$G$9!#e(B

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

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

e$B$O==J,8!F$$5$l$?$N$G$7$g$&$+!#@Q6KE*$KH?BP$J$o$1$G$O$J$$$G$9$,!"e(B
e$B$I$&$$$&%f!<%9%1!<%9$,A[Dj$5$l$F$$$k$N$+CN$j$?$$$G$9!#e(B

2.0 e$B$K$O$[$7$$$H;W$C$F$$$^$9!#e(B1.9.x e$B$OD|$a$F$$$^$9!#$[$7$$M}M3$OC1=c$Ke(B
e$BFI$_=q$-$,0W$7$$$+$i$G$9!#e(Bruby e$B$KIiC4$K$J$k$h$&$J$b$N$G$"$l$PLdBj$G$9$,!"e(B
e$B$=$&$$$&$3$H$r5a$a$F$$$^$;$s!#e(B

e$BFI$=q$-$,$d$5$7$$$N$O$o$+$k$s$G$9$,!e(B1+2i e$B$,=q$1$F$be(B 1+ni
e$B$,=q$1$J$$e(B
e$B$N$G$O$$^$jLr$KN)$?$J$$$N$G$O$J$$$+!"$H$$$&$3$H$r?4G[$7$F$$$^$9!#e(B
e$B$=$l$H$bB(CM$NJ#AG?t$r%3!<%ICf$KKd$a9~$
$?$$$H$$$&<{MW$,7k9=$"$k$b$Ne(B
e$B$J$s$G$7$g$&$+!#e(B
e$BNc$($P!V$U$J$P$5$s$N<j85$N%3!<%I$Ke(B Complex(x,
<e$B?tCM%j%F%i%ke(B>) e$B$H$$$&e(B
e$B2U=j$,;3$[$I$"$k!W$H$$$&$3$H$J$iG<[email protected]$G$-$=$&$G$9!#e(B

e$BJ8K!3HD%$^$G$9$k$J$i!"[email protected]$N8+$?L$,[email protected]$1$G$"$^$j;H$($J$$!W$b$N$Ke(B
e$B$J$k$N$O$b$C$?$$$J$$$N$G!"$b$&[email protected]$,$"$C$?J}$,$$$$$s$8$c$J$$e(B
e$B$+$J$H;W$C$F$$$^$9!#e(B

e$B%W%m%0%i%`$r=q$1$P%G%P%C%0$b$9$k$H;W$$$^$9$,!"$=$&$$$&>l9g$b%j%F%i%k$Oe(B
[email protected]$G$9!#KM$O!e(BBigDecimal e$B$r;n$7$?$j$9$k$H$-!$+$J$j$NIiC4$r46$8$^$9$h!#e(B

e$B%G%P%C%0;~$K;H$$$=$&$J$N$O3N$+$K$=$&$G$9$M!#EEBnMQES$H%G%P%C%0MQES!#e(B

e$BEEBnMQES$G$Oe(B 1+2i [email protected]$H;W$$$^$9!#[email protected]$1$J$i!"e(BRuby
e$BK\BN$G$J$/e(B irb e$B$NJ8K!$r3HD%$9$k$H$$$&A*Br;h$O$J$$$G$9$+$M!#e(B

e$B5U$K$J$s$G$=$l$re(B ruby e$BK\BN$G$d$C$F$O$$$1$J$$$N$+!"$H$$$&$3$H$K$J$k$H;We(B
e$B$$$^$9!#$$$m$$$m$J%b!<%I$r;}$A9~$`@PDM<g5A$_$J$$$J$N$O$b$&$d$a$?$i$$$$e(B
e$B$H;W$$$^$9$1$I!#e(B

e$B$&!<$s!"$d$C$Q$je(B irb
[email protected]$13HD%$H$$$&$N$O%;%s%9$J$$$G$9$M!#<h$j>C$7$^$9!#e(B

e$BFI$=q$-$,$d$5$7$$$N$O$o$+$k$s$G$9$,!e(B1+2i e$B$,=q$1$F$be(B 1+ni e$B$,=q$1$J$$e(B
e$B$N$G$O$$^$jLr$KN)$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$$&:nK!$,A}$($k$3$H$bL5$$$G$9$7!#e(B

e$B?t<0Cf$K8B$C$Fe(Bie$B$,5u?t$K$J$k!"$=$s$J$3$HCN$i$J$+$C$?!"$H$$$&?M$,8:$k$H;W$$$^$9!#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$B0l1~e(B 1+(2)i e$B$de(B 1+(n)i e$B$H$$$&J8K!$bDs0F$7$F$$$^$9!#e(B

e$B$s!<!"$=$3$^$G$d$C$F$/$l$k$H$O;W$($J$$$G$9$1$I!#e(B

e$B?t<0Cf$K8B$C$Fe(Bie$B$,5u?t$K$J$k!"$=$s$J$3$HCN$i$J$+$C$?!"$H$$$&?M$,8:$k$H;W$$$^$9!#e(B

[email protected]$+$i?t<[email protected]$C$F$P!#e(B

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

In message Re: [ruby-dev:38855] Re: e$BJ#AG?t%j%F%i%k$K$D$$$Fe(B
on Wed, 22 Jul 2009 23:51:10 +0900, Yusuke ENDOH [email protected]
writes:

|e$B$=$NA0$K!"e(B
|
|* e$BK\Ev$KI,MW$J$N$+e(B
|
|e$B$O==J,8!F$$5$l$?$N$G$7$g$&$+!#@Q6KE*$KH?BP$J$o$1$G$O$J$$$G$9$,!"e(B
|e$B$I$&$$$&%f!<%9%1!<%9$,A[Dj$5$l$F$$$k$N$+CN$j$?$$$G$9!#e(B

e$BJ#AG?t$r;H$&$3$H$,IQHK$K$"$k?M$K$O$&$l$7$$%1!<%9$,$"$k$HA[A|e(B
e$B$7$^$9!#$b$A$m$s!"$=$s$J%1!<%9$J$I$J$$!"$`$7$me(B1ie$B$H=q$1$F$b!e(B
nie$B$H=q$1$J$$$h$&$J$iMW$i$J$$!$H$$$&0U8+$,$"[email protected]$b$"$j!"e(B
e$B$=$l$O$=$l$G<*$r79$1$?$$$H;W$$$^$9!#e(B

|e$B!V%j%F%i%k!W$G$O$J$/2<5-$N$h$&$J!V5u?t2=!W$NJ8K!$K$9$l$P!">e5-$Ne(B
|e$BLdBj$O$J$/$J$k$+$b!#e(B
|
| 1+(2)i => 1+(n)i

e$B0l1~!"e(Bn.ie$B$H$$$&$b$N$bDs0F$7$F$$$^$9!#e(B

|e$BEEBnMQES$G$Oe(B 1+2i [email protected]$H;W$$$^$9!#[email protected]$1$J$i!"e(BRuby
|e$BK\BN$G$J$/e(B irb e$B$NJ8K!$r3HD%$9$k$H$$$&A*Br;h$O$J$$$G$9$+$M!#e(B

e$BEEBnMQES$GJXMx$J$i!"%W%m%0%i%_%s%0$K$bJXMx$J$s$8$c$J$$$G$9$+e(B
e$B$M$(!#e(B

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

In message Re: [ruby-dev:38852] Re: e$BJ#AG?t%j%F%i%k$K$D$$$Fe(B
on Wed, 22 Jul 2009 21:54:50 +0900, Tadayoshi F.
[email protected] writes:

|> * [email protected]$O$I$&$+!#Bg>fIW$N$O$:[email protected]$,!8+Mn$H$7$Oe(B
|
|2.0 e$B$G$O!e(B1/2 #=> (1/2) e$B$de(B 3i #=> (0+3i) e$B$J$I$H=q$1$h$&$K$G$-$?$i$$$$$He(B
|e$B8D?ME*$K4|BT$7$F$$$^$9!#$=$3$G!>/$7HyL/$J$N$Oe(B scheme e$B$N$h$&$J463P$Ge(B
|1/3i e$B$H=q$/$H!e(B1/3 e$B$b%j%F%i%k$G$$l$PLdBj$J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$rFI$JV$7$F$$^$7$?$,!5Q2<$5e(B
e$B$l$F$$$k$N$Oe(B Complex#im
(e$B$He(BNumeric#im)e$B$G$O$J$$$G$9$+$M!#$U$Je(B
e$B$P$5$s$Oe(B[ruby-dev:36421]e$B$G!V%j%F%i%k$,Ds6!$5$l$k$HB8:0U5A$,e(B
e$BGv$l$k!W$H$*$C$7$c$C$F$$$^$7$?$,!"<B:]$K:n$C$F$
$?46$8$G$Oe(B
e$B!Ve(B3ie$B$O=q$1$k$N$Ke(B ne$B!&e(Bi e$B$Oe(B n * 1i
e$B$K$J$kIT9gM}!W$r46$8$^$7$?!#e(B
e$B5u?t%j%F%i%k$O$&$l$7$$$N$O$&$l$7$$$G$9$,![email protected]$1$rA*$Ye(B
[email protected]$o$l$?$ie(B Numeric#i e$B$rA*$S$^$9$M!";d$J$i!#$G!"$?$V$se(B
Complex#i e$B$Oe(B undef e$B$9$k!#e(B

|e$B%S%k%I$G$-$J$+$C$?$N$G!"%Q%C%A$NFbMF$O$o$+$j$^$;$s$G$7$?$7!"%-!<%N!<%He(B
|e$B$bJ9$$$F$J$$$N$GH=$i$J$$$G$9$,!e(B2.0 [email protected]$r;O$a$h$&$H$$$&$3$H$Je(B
|e$B$N$G$7$g$&$+!#[email protected]$H$O$$$(!$+$J$j4X?4$,Dc$$$h$&$K;We(B
|e$B$($?$N$K!"$J$<$3$N%j%F%i%k$NOC$,:#EbFM$K=P$F$-$?$N$+!"IT;W5D$J46$8$G$9!#e(B

e$B$^$"!e([email protected]$N0l4D$G$9$,!$"$^$j$8$c$^$K$J$i$J$$$he(B
e$B$&$J$ie(B1.9.2e$B$G$b4V$K9g$&$+$J!"$H$b;W$$$^$7$?!#5^$0$h$&$J$b$N$8$ce(B
e$B$J$$$s$G!"$f$C$/$j9M$($h$&$H$$$&[email protected]$,=P$F$b!"$=$l$O$=$l$G9=e(B
e$B$$$^$;$s$,!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(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