Rational, complex and nuby

ruby e$B$Ke(B rational e$B$He(B complex e$B$rAH$$3$b$&$H;n$7$F$$$Fe(B
nuby e$B$H$$$&GI@8J*e(B
e$B$r:n$C$F$
$^$7$?!#$J$K$+LdBj$,$"$C$?$i65$($F$/$@$5$$!#e(B

mathn e$B$,4pK$GM-8z$G$9!#e(B

2 / 3 #=> (2/3)

e$BJXMx$N$?$a$K!“$”$?$i$7$$1i;;;Re(B // (div) e$B$rF3F~$7$^$7$?!#e(B

2 // 3 #=> 0

e$B$"$?$i$7$$%j%F%i%k$rF3F~$7!"0J2<$N$h$&$K=q$/$3$H$b$G$-$^$9!#e(B

10r3 #=> (10/3)
10.5c3 #=> (10.5+3i)
3i #=> (3i)

e$B9b!90l2s$@$1I>2A$5$l$kI=8=$r$D$1$F$_$^$7$?!#e(B

def foo(x) (# 3 * x) end
foo(3) #=> 9
foo(30) #=> 9

class Integer; def days() self * (#24 * 60 * 60) end; end
3.days #=> 259200

$ inuby -m
inuby@main> 0.3.numerator / 0.3.denominator + 3i
#=>
5404319552844595
-----------------+3i
18014398509481984

e$BB>$K$b$[$7$$%a%=%C%I$J$I$rDI2C$7$F$"$j$^$9!#e(B

rational e$B$He(B complex e$B$O@PDM$5$s$N<BAu$r;29M$Ke(B C
e$B$G=q$-D>$7$^$7$?!#86$5e(B
e$B$s$H$N5DO@$b;29M$K$J$C$?$H;W$$$^$9!#e(B

e$BFMA3:n$C$?$N$G;($G$9$,!"<+J,$,$[$7$$$H;W$C$F$$$?$b$N$,$D$+$($k$h$&$K$J$Ce(B
e$B$F$$$k$H3Z$7$$$G$9!#e(B

http://www.funaba.org/archive/nuby-1.86.000.tar.gz

e$B$J$+$@$G$9!#e(B

At Sat, 2 Feb 2008 14:46:40 +0900,
Tadayoshi F. wrote in [ruby-dev:33567]:

ruby e$B$Ke(B rational e$B$He(B complex e$B$rAH$$3$b$&$H;n$7$F$$$Fe(B nuby e$B$H$$$&GI@8J*e(B
e$B$r:n$C$F$
$^$7$?!#$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$j$9$k2De(B
e$BG=@-$r9M$($k$H!"%P%j%"$,I,MW$K$J$k$O$:$G$9!#e(B

2002/01/25e$BHG$K$=$N8e$N=$@5$r<j$GDI2C$7$?>uBVe(B? ChangeLoge$B$r$_$?$i!"e(B
e$B$J$s$@$+L/$J46$8$G$9$,!#e(B

e$B$=$&$G$9$M!#e(B

e$B$=$l0J30$K$b$$$/$D$+JQ99$,2C$($i$l$F$$$k$h$&$G$9$,!"$I$&$$$C$?$b$N$G$7$ge(B
e$B$&$+!#e(B

String#to_r e$B$de(B Float#to_r e$B$,!"$J$$$N$b$+$J$jITJX$G!"$=$&$$$&7g$1$F$$$ke(B
e$B$H$3$m$r$J$k$Y$/Jd$*$&$H$7$F$$$^$9!#e(B

e$B$3$l$O:#8e$NM=Dj$G$7$g$&$+!#e(B

e$B$$$(!"$"$j$^$9$h!#e(B

$ nuby -e ‘p “-1/3”.to_r’
(-1/3)

$ nuby -e ‘p 0.3.to_r’
(5404319552844595/18014398509481984)

$ nuby -e ‘p “1/3+5i”.to_c’
(1/3+5i)

e$B$3$N$"$?$j$O!“e(Bruby
e$B$G=q$$$F$”$k$N$G$9$,!"$=$3$r8+$F$J$$$N$@$H;W$$$^$9!#e(B
e$B$J$+$@$5$s$O!"%=!<%9$rD/$a$F$k$@$1$G!"F0$+$7$F$O$$$J$$$H;W$&$N$G$9$,!#e(B

x.quotient(y) e$B$Oe(B x.quo(y).floor e$B$H@:EY$r=|$$$F$OEy2A$G$9$+!#e(B

e$B$$$(!#e(Bquotient (quot) e$B$O!"e(BScheme (r5rs e$B$^$Ge(B)
e$B$N$=$l$d!"e(BCommon Lisp e$B$Ne(B
truncate e$B$N$R$H$DL$NCM!"e(BSmalltalk e$B$Ne(B quo
e$B$HF1MM$H9M$($^$9!#$J$N$Ge(B
truncate e$B$N$[$&$G$9$+$M!#e(B

divmod = div + mod --> CL e$B$Ne(B floor
quotrem = quot + rem --> CL e$B$Ne(B truncate

$ ruby -e ‘p -11.quo(3).floor’
-4

$ ruby -e ‘p -11.quo(3).truncate’
-3

$ nuby -e ‘p -11.quot(3)’
-3

scm> (quotient -11 3)
-3

[1]> (floor -11 3)
-4 ;
1
[2]> (truncate -11 3)
-3 ;
-2

e$B$$$d!"$=$3$^$G:o$C$A$c$&$N$O$I$&$+$H;W$$$^$9$,!#e(B

e$B$s!<!"$=$&$G$9$+!#e(BNumeric#floor e$BI,MW$G$9$+!#e(BInteger
e$B$K$OMW$i$J$$$7!“e(B
Rational e$B$de(B Complex
e$B$K$bE,$5$J$$$H;W$&$N$G$9!#0UL#$”$k$N$O!"e(BFloat e$B$@$1e(B
e$B$8$c$J$$$G$9$+!#e(B

IFFERENCESe$B$r$_$k$He(BArray#stable_sort!e$B$J$I$Oe(Badded methodse$B$H$J$C$Fe(B
e$B$$$^$9$,!"<BAu$O$5$l$F$$$J$$$h$&$K8+$($^$9!#e(Bto_re$B$J$I$HF1$8$/:#8ee(B
e$B$NM=Dje(B?

e$B$3$l$be(B ruby e$B$G=q$$$F$"$j$^$9!#e(Bonce
(e$B%a%=%C%I$Ne(B)e$B!"e(Bstable_sorte$B!“e(Brational
e$B$He(B complex e$B$r4^$`0lIt$Ne(B Numeric e$B$N%a%=%C%Ie(B
e$B$J$I$O!”$=$&$J$C$F$^$9!#e(B

Thread.criticale$B$GF0$/$N$G6%9g>r7o$GF0$+$J$$$H$$$&$N$O@53N$G$O$Je(B
e$B$$$G$9$M!#Nc30$,5/$-$?$H$-$Ke(Bcriticale$B$N$^$^$K$J$C$F$7$^$&$N$O$9$0e(B
e$BD>$k$G$7$g$&$,!":FF~2DG=@-$H$+FbIt$Ge(Bcriticale$B$G$J$/$J$C$?$j$9$k2De(B
e$BG=@-$r9M$($k$H!"%P%j%"$,I,MW$K$J$k$O$:$G$9!#e(B

e$B$J$+$@$5$s$b$[$7$$$H;W$$$D$D!"<j$r=P$7$F$$$J$$$H$3$m$r8+$k$HFq$7$G$9$+e(B
e$B$M!#>/$/$H$b8=;~E@$G$3$l$r??7u$K$D$+$$&$H;W$&?M$O$$$J$$$H;W$&$N$G!"Eve(B
e$BLL$OJ|CV$7$F$
$3$&$+$H;W$$$^$9!#e(B

e$BKM$H$7$F$O!“e(Bruby
e$B$G$3$s$J$3$H=PMh$?$iLLGr$$$h$M!”$H$$$&$3$H$r8+$;$i$le(B
e$B$l$P==J,$@$H;W$C$F$$$k$N$G!#$^$"!"$[$7$$$G$9$,!"e(Bruby e$B$K$b!#e(B

e$B$J$+$@$G$9!#e(B

At Sun, 3 Feb 2008 11:10:45 +0900,
Tadayoshi F. wrote in [ruby-dev:33573]:

e$B$3$N$"$?$j$O!“e(Bruby e$B$G=q$$$F$”$k$N$G$9$,!"$=$3$r8+$F$J$$$N$@$H;W$$$^$9!#e(B
e$B$J$+$@$5$s$O!"%=!<%9$rD/$a$F$k$@$1$G!"F0$+$7$F$O$$$J$$$H;W$&$N$G$9$,!#e(B

e$B$?$7$+$K!#e(Blib/prelude.rbe$B$G$7$?$+!#e(B

e$B$A$g$C$H8+$?$H$3$m!"e(BEnumerable#stable_sort_bye$B$,e(Bsorte$B$r;H$C$F$$$ke(B
e$B$N$G0BDj$G$J$$$h$&$G$9!#e(B

$ ./nuby -e ‘a=[];%w[def abc def abc].each_with_index{|*e|a<<e}; p
a.stable_sort{|e,f|e[0]<=>f[0]}’
[[“abc”, 1], [“abc”, 3], [“def”, 0], [“def”, 2]]
$ ./nuby -e ‘a=[];%w[def abc def abc].each_with_index{|*e|a<<e}; p
a.stable_sort_by{|e,i|e}’
[[“abc”, 3], [“abc”, 1], [“def”, 2], [“def”, 0]]

x.quotient(y) e$B$Oe(B x.quo(y).floor e$B$H@:EY$r=|$$$F$OEy2A$G$9$+!#e(B

e$B$$$(!#e(Bquotient (quot) e$B$O!"e(BScheme (r5rs e$B$^$Ge(B) e$B$N$=$l$d!"e(BCommon Lisp e$B$Ne(B
truncate e$B$N$R$H$DL$NCM!"e(BSmalltalk e$B$Ne(B quo e$B$HF1MM$H9M$($^$9!#$J$N$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8L>JN,$r;_$a$F$b$$$$$H;W$$$^$9!#e(B

e$B$H$j$"$($:!“e(Brational e$B$He(B complex e$B$NAH$_$3$e(B
(e$BL$$@$"$^$j$A$c$s$HAH$
$3$ae(B
e$B$F$J$$$1$Ie(B)e$B!”%j%F%i%k$NF3F~$"$?$j$O:#2s$N<g4c$@$C$?$N$G!"$=$3$,!V$^$!e(B
e$B$$$$$s$8$c$J$$$+!W$J$i!"==J,$G$7$g$&!#e(B

e$B$"$H!"e(B//=e$B$,L$BP1~$N$h$&$G$9!#e(B

e$B$$!"$=$l$O40`z$KK:$l$F$$$^$7$?!#e(B

e$B3g8L>JN,<+BN$O;_$a$k$o$1$K$O$$$+$J$$$H;W$$$^$9$,!"$b$&>/$7@0M}$Ge(B
e$B$-$k$N$G$O$J$$$+$H;W$$$^$9!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#e(B

e$B$J$+$@$G$9!#e(B

At Sun, 3 Feb 2008 17:33:54 +0900,
Tadayoshi F. wrote in [ruby-dev:33575]:

e$B$=$l$O$I$&$G$9$+$M!#e(BNumeric#floor e$B$N<BAu$O!"$<$s$<$s0lHLE*$J2r7h$K$J$Ce(B
e$B$F$J$$$s$G$9$h!#e(Brational e$B$G$O!"JLES<BAu$9$Y$-$G$9!#e(Bruby e$B$G$O!“Cj>]%/%ie(B
e$B%9$G!”%W%m%H%3%k$J$j%$%s%?!<%U%’%$%9$r<($9$H$$$&$3$H$b$J$$$N$G!"e(BFloat
e$B$G$7$+0UL#$N$J$$$b$N$re(B Numeric e$B$KCV$$$F$*$/I,MW$O$J$$$H;W$$$^$9!#e(B

floor e$B$@$1$8$c$J$$$G$9$h!#e(Btruncatee$B!"e(Bceile$B!"e(Bround e$B$bF1$8$G$9!#e(B

Floate$B8GM-$N$b$N$O$9$Y$Fe(BNumerice$B$G$O$J$/e(BFloate$B$K!"$H$$$&$3$H$G$9$+!#e(B
e$B$=$l$OG<F@$G$9!#e(B

Rationale$B$de(BComplexe$B$NAH9~$_$O!"%j%F%i%k$b4^$a$F$^$!$$$$$s$8$c$J$$e(B
e$B$+$H;W$&$N$G$9$,!"e(Bmathne$B$O$I$&$G$7$g$&$M$’!#>/$J$/$H$b!"e(B//e$B1i;;;Re(B
e$B$K$O$$$5$5$+Dq93$r46$8$^$9!#$?$H$($Pe(B string.split // e$B$J$I$H$$$&e(B
e$B$b$N$,e(Bsyntax errore$B$K$J$C$F$7$^$&$3$H$H$+!#e(B

e$B$^$"!“4JC1$Ke(B ruby e$B$K:NMQ$5$l$J$$$h$&$@$,$i!”$3$&$$$&$b$N$r:n$C$F$_$?$oe(B
e$B$1$G$9$1$I!"<B:]$K$O!"$?$$$7$?1F6A$O$J$$$h$&$K46$8$F$$$^$9!#e(B// e$B<+BN$O!“e(B
Smalltalk e$B$de(B Python e$B$K$b$”$k$N$G!"?74q$J$b$N$G$b$J$$$G$9$7!#e(B

Pythone$B$@$He(B//e$B$Oe(Binte$B$8$c$J$/$Fe(Bfloate$B$rJV$9$h$&$G$9$M!#e(B

e$B$"$H!"e(B//=e$B$,L$BP1~$N$h$&$G$9!#e(B

e$BJ8K!>e$N2]Bj$H$7$F$O!“3g8L$N$”$D$+$$$N$[$&$,%G%+$$$N$G!"$`$7$m!"0z?t$Ne(B
e$B3g8L>JN,$r;_$a$F$b$$$$$H;W$$$^$9!#e(B

e$B3g8L>JN,<+BN$O;_$a$k$o$1$K$O$$$+$J$$$H;W$$$^$9$,!"$b$&>/$7@0M}$Ge(B
e$B$-$k$N$G$O$J$$$+$H;W$$$^$9!#e(B

— parse.y~ 2008-02-02 13:47:15.000000000 +0900
+++ parse.y 2008-02-03 17:57:07.000000000 +0900
@@ -4259,21 +4259,22 @@ yylex()
return tOP_ASGN;
}

  • if (c == ‘/’) {
  •  if ((c = nextc()) == '=') {
    
  • yylval.id = tIDIV;
  • lex_state = EXPR_BEG;
  • return tOP_ASGN;
  •  }
    
  •  else {
    
  • pushback©;
  • return tIDIV;
  •  }
    
  • }
    pushback©;
  • {
  • int c2;
  • if ((c2 = nextc()) != ‘/’) {
  •  pushback(c2);
    
  •  if (IS_ARG() && space_seen) {
    
  •    if (!ISSPACE(c)) {
    
  • if (IS_ARG() && space_seen) {
  •  if (!ISSPACE(c)) {
    
    arg_ambiguous();
    lex_strterm = NEW_STRTERM(str_regexp, ‘/’, 0);
    return tREGEXP_BEG;
  •    }
     }
    
  • } else {
  •  pushback(c2);
    
  • }
    }
    switch (lex_state) {
    @@ -4283,8 +4284,4 @@ yylex()
    lex_state = EXPR_BEG; break;
    }
  • if ((c = nextc()) == ‘/’) {
  •  return tIDIV;
    
  • }
  • pushback©;
    return ‘/’;

Pythone$B$@$He(B//e$B$Oe(Binte$B$8$c$J$/$Fe(Bfloate$B$rJV$9$h$&$G$9$M!#e(B

Python e$B$N>l9g!“e(Bdivmod
e$B$b0z?t$N$I$A$i$+$,!“IbF0>.?tE@?t$J$i7k2L$b$=$&$Je(B
e$B$k$N$G!”$=$l$O$=$l$G9M$($,$”$k$s$G$7$g$&$M!#e(B

e$B$"$H!"e(B//=e$B$,L$BP1~$N$h$&$G$9!#e(B

e$B%Q%C%A$r$_$^$7$?$,!"$3$N$^$^$@$H!“J8K!%(%i!<$K$J$k>l9g$,$”$j$^$9$M!#0Je(B
e$BA0$N$h$&$K!"e(B/ e$B$HF1MM!"e(Blex_state e$B$N@_Dj$,I,MW$J$N$+$J!#e(B

e$B$J$+$@$G$9!#e(B

At Mon, 4 Feb 2008 00:26:02 +0900,
Tadayoshi F. wrote in [ruby-dev:33579]:

Pythone$B$@$He(B//e$B$Oe(Binte$B$8$c$J$/$Fe(Bfloate$B$rJV$9$h$&$G$9$M!#e(B

Python e$B$N>l9g!“e(Bdivmod e$B$b0z?t$N$I$A$i$+$,!“IbF0>.?tE@?t$J$i7k2L$b$=$&$Je(B
e$B$k$N$G!”$=$l$O$=$l$G9M$($,$”$k$s$G$7$g$&$M!#e(B

e$B$J$s$H$J$/;W$C$?$N$G$9$,!“e(B/e$B$O@0?t=|;;e(B(e$B$H$$$&$+%*%Z%i%s%I$N7?e(B)e$B$Ne(B
e$B$^$^$K$7$F!”?7$?$Ke(B//e$B$rDI2C$7$Fe(BFloate$B$de(BRationale$B$rJV$9$h$&$K$9$k$He(B
e$B$$$&$N$G$O$^$:$$$N$G$7$g$&$+!#e(B

e$B;;?t$G$b!"e(B10e$B!`e(B3=3…1

e$B$H$$$&Iw$K@0?t1i;;$+$i;O$^$C$F!"J,?t$d>/e(B

e$B?t$,=P$F$/$k$N$O$=$N8e$G$9$h$M!#F|K\0J30$N;v>p$OCN$j$^$;$s$,!#e(B

e$B$"$H!"e(B//=e$B$,L$BP1~$N$h$&$G$9!#e(B

e$B%Q%C%A$r$_$^$7$?$,!"$3$N$^$^$@$H!“J8K!%(%i!<$K$J$k>l9g$,$”$j$^$9$M!#0Je(B
e$BA0$N$h$&$K!"e(B/ e$B$HF1MM!"e(Blex_state e$B$N@_Dj$,I,MW$J$N$+$J!#e(B

e$B$I$&$$$&>l9g$G$7$g$&$+!#e(B

e$B$$$/$D$+$N%P%0$rD>$7!“e(Bxor
e$B1i;;;R$J$I!”$$$/$D$+5!G=DI2C$7$^$7$?!#:#8e$be(B
e$B$-$^$0$l$K5!G=DI2C$J$I$7$F$$$3$&$H;W$$$^$9!#e(B

e$B$“$H!”$;$C$+$/$J$N$G!"e(Brational e$B$He(B complex
e$B$N<BAu$bJLESG[I[$7$^$9!#e(B

http://www.funaba.org/archive/nuby-1.86.001.tar.gz

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

Tadayoshi F. e$B$5$s$O=q$-$^$7$?e(B:

ruby e$B$Ke(B rational e$B$He(B complex e$B$rAH$$3$b$&$H;n$7$F$$$Fe(B nuby e$B$H$$$&GI@8J*e(B
e$B$r:n$C$F$
$^$7$?!#$J$K$+LdBj$,$"$C$?$i65$($F$/$@$5$$!#e(B

e$B$H$F$b6=L#?<$/;W$$$^$7$?!#8_49@-$h$j!V;d$@$C$?$i!D!W$rM%@h$5$;$?!";W$$@Z$j$,e(B
e$B$$$$$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^$D$b$H$5$s$K:n$C$F$/$l$H$4je(B
e$B$$$7$?$H$3$m!":G=iFq$7$$$H$$$&46$8$@$?$s$G$9$,!"$=$N$&$A!"=PMh$k$+$b$7e(B
e$B$l$J$$$H$$$&46$8$K$J$j!";n83E
$KF~$l$F$_$h$&$H$$$&$3$H$K$J$C$F!":#$G$Oe(B
e$B$"$?$j$^$($N$h$&$K;EMM$K$J$C$F$^$9!#$=$N5-21$,$"$C$F8@$&$N$G$9$,!"e(B

e$BM-M}?t$N@8@.$K!"5-9fe(B : e$B$r;H$&$3$H$O$G$-$J$$$G$7$g$&$+!)e(B

e$B$D$^$j!"e(BInteger#: e$B$r:n$k$H$$$&$3$H$G$9!#e(B

e$BM-M}?t$N@8@.$K!"5-9fe(B : e$B$r;H$&$3$H$O$G$-$J$$$G$7$g$&$+!)e(B

e$B$o$+$j$^$;$s$,!"$J$+$@$5$s$N$$$&$h$&$K!"%3%m%sBg3hLv$Ne(B ruby
e$B$J$N$G!"e(B3
e$B9`1i;;;R$G$D$+$$$E$i$$$H$+!"e(B1.9
e$B$N%O%C%7%eI=8=$HHo$k$H$+$GBgJQ$J$s$8$ce(B
e$B$J$$$G$7$g$&$+!#e(B

e$B$J$+$@$G$9!#e(B

At Wed, 13 Feb 2008 12:03:58 +0900,
Shin-ichiro HARA wrote in [ruby-dev:33728]:

e$BM-M}?t$N@8@.$K!"5-9fe(B : e$B$r;H$&$3$H$O$G$-$J$$$G$7$g$&$+!)e(B

e$B$D$^$j!"e(BInteger#: e$B$r:n$k$H$$$&$3$H$G$9!#e(B

e$B$_$s$J!"%3%m%s$r9s;H$7$9$.$G$9!#e(B

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

In message “Re: [ruby-dev:33774] Re: Rationale$B@8@.$Ke(B :
e$B$O;H$($J$$!)e(B”
on Thu, 14 Feb 2008 16:45:02 +0900, Shin-ichiro HARA
[email protected] writes:

|> e$B$$s$J!“%3%m%s$r9s;H$7$9$.$G$9!#e(B
|
|e$B$&!”=V;&e(B(;
:wink:

Rationale$B$,AH$9~$$J$ie(B 11/25 e$B$Ge(BRationale$B$H$+!#e(B

                            e$BL5KEe(B
                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

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

e$B$_$s$J!"%3%m%s$r9s;H$7$9$.$G$9!#e(B

e$B$&!"=V;&e(B(;_:wink:

|> e$B$$s$J!"%3%m%s$r9s;H$7$9$.$G$9!#e(B
|
|e$B$&!"=V;&e(B(;
:wink:

Rationale$B$,AH$9~$$J$ie(B 11/25 e$B$Ge(BRationale$B$H$+!#e(B

                            e$BL5KEe(B
                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)

e$B$^$?!"$4Mp?4$H$+$$$o$l$A$c$$$^$9$h!#e(B

e$B!t!V$^$?!W$C$F!De(B