Patch for ruby-core:17472

e$B%o%J%Y$H?=$7$^$9!#e(B

[ruby-core:17472] [Ruby 1.8 - Bug #206]
e$B$KBP$9$k%Q%C%A$r=q$-$^$7$?!#e(B
e$B<j85$G$O0lDL$j%F%9%H$7$?$D$b$j$G$9$,!"$3$l$G$$$$$N$+$$$^$$$A3N?.$,$b$F$^$;$s!#e(B
e$B$I$J$?$+8!>[email protected]$1$J$$$G$7$g$&$+!#e(B

Index: ext/bigdecimal/bigdecimal.c

— ext/bigdecimal/bigdecimal.c (revision 17888)
+++ ext/bigdecimal/bigdecimal.c (working copy)
@@ -973,10 +973,8 @@
return (VALUE)0;
}

  • mx = a->Prec;
  • if(mxPrec) mx = b->Prec;
  • mx =(mx + 1) * VpBaseFig();
  • GUARD_OBJ(c,VpCreateRbObject(mx, “0”));
  • mx =(a->MaxPrec + b->MaxPrec + 1) * VpBaseFig();
  • GUARD_OBJ(c,VpCreateRbObject(mx, “#0”));
    GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1),
    #0”));
    VpDivd(c, res, a, b);
    mx = c->Prec *(VpBaseFig() + 1);

[email protected]$G$9!#e(B

At Sat, 5 Jul 2008 22:51:48 +0900,
wanabe wrote in [ruby-dev:35372]:

[ruby-core:17472] [Ruby 1.8 - Bug #206] e$B$KBP$9$k%Q%C%A$r=q$-$^$7$?!#e(B
e$B<j85$G$O0lDL$j%F%9%H$7$?$D$b$j$G$9$,!"$3$l$G$$$$$N$+$$$^$$$A3N?.$,$b$F$^$;$s!#e(B
e$B$I$J$?$+8!>[email protected]$1$J$$$G$7$g$&$+!#e(B

BigDecimal(‘1’).div(BigDecimal(‘3E-9’)) e$B$N7k2L$NM-8z?t;z$,0l7e$Ke(B
e$B$J$k$H$$$&$N$O!"$b$7$+$7$F;EMM$I$*$j$NF0:n$J$s$8$c$J$$$G$7$g$&$+!#e(B
e$B:8JU$b1&JU$b!“e(B(e$B$”$k$$$O%l%7!<%P$b0z?t$be(B)e$BM-8z?t;z0l7e$G$9$+$i!#e(B

e$B0lJ}$G!"$J$<$+e(BBigDecimal#/e$B$G$OM-8z?t;z$,A}$($?$j$9$k$N$G!";H$$J,e(B
e$B$1$m$H$$$&$3$H$J$s$G$7$g$&$+!#$$$:$l$K$;$h!">.NS$5$s$G$J$$$HH=CGe(B
e$B$O$D$1$i$l$J$$$H;W$$$^$9!#e(B

e$B%o%J%Y$G$9!#e(B

2008/07/06 15:36 Nobuyoshi N. [email protected]:

BigDecimal(‘1’).div(BigDecimal(‘3E-9’)) e$B$N7k2L$NM-8z?t;z$,0l7e$Ke(B
e$B$J$k$H$$$&$N$O!"$b$7$+$7$F;EMM$I$*$j$NF0:n$J$s$8$c$J$$$G$7$g$&$+!#e(B
e$B:8JU$b1&JU$b!“e(B(e$B$”$k$$$O%l%7!<%P$b0z?t$be(B)e$BM-8z?t;z0l7e$G$9$+$i!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#$J$k$[$I!#e(B

BigDecimal(‘1’).divmod(BigDecimal(‘3E-9’)) #=> [0.3E9, 0.1E0]

e$B>e$N$h$&$KM>$j$,3d$k?t$r>e2s$k$N$,M}2r$G$-$:e(B
e$B%P%0$+$H;W$C$?$N$G$9$,!"$=$&$$$&$3$H$G$7$?$iG<[email protected]$7$^$7$?!#e(B

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

2008e$BG/e(B7e$B7ne(B7e$BF|e(B18:23 wanabe [email protected]:

e$B%P%0$+$H;W$C$?$N$G$9$,!"$=$&$$$&$3$H$G$7$?$iG<[email protected]$7$^$7$?!#e(B
e$B$3$l$O$d$O$j%P%[email protected]$H;W$$$^$9!#e(B

e$B$3$s$J$3$HK\[email protected]$$$?$/$J$$$N$G$9$,!“K\Ev$K;DG0$J$3$H$Ke(B
bigdecimal e$B$Oe(B
Java e$B$Ne(B BigDecimal e$B$K4p$E$$$?<BAu$K$J$C$F$7$^$C$F$$$^$9!#e(B
e$B$=$7$Fe(B Java e$B$Ne(B BigDecimal
e$B$O!”>o<1E*$J!VM-8z?t;z!W$H$O0[$J$k;WA[$Ke(B
e$B4p$E$$$F$$$k$h$&$G$9e(B
(e$B2C8:;;$J$I$,!VM-8z?t;z!W$r>!<j$KA}$d$9$N$b;EMMe(B) e$B!#e(B

http://java.sun.com/javase/ja/6/docs/ja/api/java/math/BigDecimal.html

e$B0l9o$bAa$/e(B bigdecimal e$B$rEj$2<N$F$?$$!#e(B

e$B$=$7$F!"$=$Ne(B Java e$B$K$*$$$F$be(B divideAndRemainder e$B$Oe(B
333… e$B$rJV$7$^$9!#e(B

scala> new BigDecimal(“1”) divideAndRemainder new BigDecimal(“3E-9”)
res0: Array[java.math.BigDecimal] = Array(333333333, 1E-9)

e$B$h$C$F$3$N%Q%C%A$O$"$F$k$Y$-$G$9!#e(Brubyspec
e$B$N%(%i!<$b>C$($^$9!#e(B

e$B%o%J%Y$5$s!"$*4j$$$7$F$$$$$G$7$g$&$+!#e(B

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

On 2010/02/07, at 16:06, Yusuke ENDOH wrote:

BigDecimal(‘1’).divmod(BigDecimal(‘3E-9’)) #=> [0.3E9, 0.1E0]

e$B>e$N$h$&$KM>$j$,3d$k?t$r>e2s$k$N$,M}2r$G$-$:e(B
e$B%P%0$+$H;W$C$?$N$G$9$,!"$=$&$$$&$3$H$G$7$?$iG<[email protected]$7$^$7$?!#e(B

e$B$3$l$O$d$O$j%P%[email protected]$H;W$$$^$9!#e(B

e$B$o$?$7$b%P%[email protected]$H;W$$$^$9!#e(B
BigDecimal#divmod e$B$N5sF0$Oe(B Float#divmod e$B$K9g$o$;$F!"e(B

  • e$B>&[email protected]?te(B
  • e$B=|?te(B > 0 e$B"Me(B 0 <= e$B>jM>e(B < e$B=|?te(B
  • e$B=|?te(B < 0 e$B"Me(B e$B=|?te(B < e$B>jM>e(B <= 0

e$B$H7h$a$?J}$,NI$$$H;W$$$^$9!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

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$B1sF#$G$9!#e(B

2010e$BG/e(B2e$B7ne(B7e$BF|e(B16:06 Yusuke ENDOH [email protected]:

e$B>e$N$h$&$KM>$j$,3d$k?t$r>e2s$k$N$,M}2r$G$-$:e(B
e$B%P%0$+$H;W$C$?$N$G$9$,!"$=$&$$$&$3$H$G$7$?$iG<[email protected]$7$^$7$?!#e(B

e$B$3$l$O$d$O$j%P%[email protected]$H;W$$$^$9!#e(B

*snip

e$B$h$C$F$3$N%Q%C%A$O$"$F$k$Y$-$G$9!#e(Brubyspec e$B$N%(%i!<$b>C$($^$9!#e(B

e$B$9$_$^$;$s!"e(Brubyspec e$B$K$D$$$F$O13$G$7$?!#e(B

e$B<j85$G;n9T:x8m$7$F$$$F!“0J2<$N$h$&$J%Q%C%A$K$7$F!“e(Brubyspec
e$BB&$be(B
/ e$B$G$J$/e(B div
e$B$r;H$&$h$&[email protected]$7$?>e$G!”$d$C$HDL$C$F$$$^$9!#$,!“e(B
e$B%o%J%Y$5$s$N%Q%C%[email protected]:EY$r>!<j$Ke(B 2
e$BG$K$”$2$F$$$k$N$G!”$?$V$se(B
e$B%@%a$J%Q%C%A$G$9!#e(B

mrkn e$B$5$s$,$A$c$s$H9M$($FD>$7$F$/$l$k$H?.$8$F$$$^$9!#e(B

diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 8e85fdf…661b238 100644
— a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -970,10 +970,8 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real
**div, Real **mod)
return Qtrue;
}

  • mx = a->Prec;
  • if(mxPrec) mx = b->Prec;
  • mx =(mx + 1) * VpBaseFig();
  • GUARD_OBJ(c,VpCreateRbObject(mx, “0”));
  • mx = (a->MaxPrec + b->MaxPrec + 1) * 2 * VpBaseFig();
  • GUARD_OBJ(c,VpCreateRbObject(mx, “#0”));
    GUARD_OBJ(res,VpCreateRbObject((mx+1) * 2 +(VpBaseFig() + 1),
    #0”));
    VpDivd(c, res, a, b);
    mx = c->Prec *(VpBaseFig() + 1);
    @@ -983,6 +981,7 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real
    **div, Real **mod)
    VpAddSub(c,a,res,-1);
    if(!VpIsZero© && (VpGetSign(a)*VpGetSign(b)<0)) {
    VpAddSub(res,d,VpOne(),-1);
  • GUARD_OBJ(d,VpCreateRbObject(GetAddSubPrec(c, b)*(VpBaseFig() + 1),
    “0”));
    VpAddSub(d ,c,b, 1);
    *div = res;
    *mod = d;

diff --git a/library/bigdecimal/divmod_spec.rb
b/library/bigdecimal/divmod_spec.rb
index 5ea6d82…d3a47fc 100644
— a/library/bigdecimal/divmod_spec.rb
+++ b/library/bigdecimal/divmod_spec.rb
@@ -143,7 +143,7 @@ describe “BigDecimal#divmod” do
values.each do |val2|
res = val1.divmod(val2)
DivmodSpecs::check_both_bigdecimal(res)

  •      res[0].should == ((val1/val2).floor)
    
  •      res[0].should == val1.div(val2)
         res[1].should == (val1 - res[0] * val2)
       end
     end

e$BB<ED$G$9!#e(B

On 2010/02/07, at 22:04, TOYOFUKU Chikanobu wrote:

e$B$K$OM-8z7e?t$,B-$j$J$$$N$GNc30$K$9$k$Y$-$G$7$g$&$+!#e(B
[email protected]$r;}$?$;$?$$$H$3$m$G$9!#e(B

e$B$H$b$+$/e(B BigDecimal e$B$Ne(B mod, divMod e$B$K4X$7$F$O$^$:0UL#$r7h$a$ke(B
[email protected]$H;W$$$^$9!#e(BInt, Float [email protected]$r9M$($k$He(B mod, divMod
e$B$H$$$&%a%=%C%I$ODj5A$9$Y$-$G$J$$$N$+$b$7$l$^$;$s!#e(B

1.9 e$B$K$Oe(B Integere$B!“e(BRational
e$B$H$$$&[email protected]$J?t$,AH$9~$$GMQ0U$5$l$F$$$^$9!#e(B
[email protected]$J?t$NI=8=$O$3$l$i$K>y$C$F!”$9$Y$F$Ne(B BigDecimal
[email protected]:EY$r;}$De(B
e$B$3$H$K$7$F$7$^$C$FLdBj$O$"$k$G$7$g$&$+!)e(B

e$B$b$7LdBj$,$J$$$h$&$J$i!">e5-$NNcBj$Oe(B Mathematica
e$B$HF1$8$K$7$?$$$G$9!#e(B
Mathematica e$B$G$O<!$N$h$&$K$J$j$^$9!#e(B

In[1]:= N[Sin[N[100000000, 1]], 100]

Out[1]= 0.

In[2]:= Mod[N[100000000, 1], 3]

Out[2]= 0.*10^7


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

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%o%J%Y$H?=$7$^$9!#e(B

10/02/07 Yusuke ENDOH [email protected]:

e$B>e$N$h$&$KM>$j$,3d$k?t$r>e2s$k$N$,M}2r$G$-$:e(B
e$B%P%0$+$H;W$C$?$N$G$9$,!"$=$&$$$&$3$H$G$7$?$iG<[email protected]$7$^$7$?!#e(B

e$B$3$l$O$d$O$j%P%[email protected]$H;W$$$^$9!#e(B
e$B!JCfN,!Ke(B
e$B$h$C$F$3$N%Q%C%A$O$"$F$k$Y$-$G$9!#e(Brubyspec e$B$N%(%i!<$b>C$($^$9!#e(B

e$B%o%J%Y$5$s!"$*4j$$$7$F$$$$$G$7$g$&$+!#e(B

e$BBgJQ?=$7Lu$"$j$^$;$s!#e(B
e$B>p$1$J$$OC$J$N$G$9$,!"%Q%C%A$N0UL#$r3P$($F$*$i$:H=CG$G$-$+$M$^$9!#e(B
[email protected]$r8+$k$H!"5?Ld$NM>CO$N$J$$%P%0$G$O$J$/0UL#[email protected]!&;EMM$KF’$_9~$`$h$&$G$9$N$Ge(B
e$B%a%s%F%J$^$?$O$^$D$b$H$5$s$N7hDj$,I,MW$G$O$J$$$+$H;W$$$^$9!#e(B

e$B$G$9$N$G!"$^$D$b$H$5$s$+!"$"$k$$$O%a%s%F%J$H$7$F>5G’$5$l$?8e$G$"$l$PB<ED$5$s$,e(B
e$B%3%_%C%H$;$h$H$$$&$N$G$"$l$P$=$&$7$^$9$7!"[email protected]$,I,MW$G$"$l$P$=$l$O$h$m$7$/$*4j$$$7$^$9!#e(B

e$B$b$72?$+$N;v>p$G6[5^@-$,$"$k!"$H$j$"$($:$G$$$$$+$i%3%%C%H$7$F$[$7$$!"$H$$$&$3$H$G$"$l$Pe(B
e$BLdBj$,$"$l$P$9$0$Ke(B revert
e$B$9$kA0Ds$G%3%
%C%H$5$;[email protected]$-$^$9!#e(B

e$BK-J!$G$9!#e(B

  • e$B=|?te(B > 0 e$B"Me(B 0 <= e$B>jM>e(B < e$B=|?te(B

e$B;d$b$3$NA0e(B mod e$B$K!V>jM>e(B <
e$B=|?t!W$r4|BT$9$k$H=q$-$^$7$?$,2~$a$Fe(B
e$B9M$($?$i!“Nc$($Pe(B
(e$BM-8z7e?t#17e$G#12/e(B).mod(e$B!JM-8z7e?t$$$/$D$G$”$m$&$,!Ke(B3)
e$B$K$O0UL#$N$"$kCM$H$7$F2?$r4|BT$9$Y$-$G$7$g$&$+!#e(B
x = BigDecimal(“1E8”); sin(x,100) e$B$Oe(B sin([email protected]$J#12/e(B,100)
e$B$H$7$Fe(B
e$B7W;;$9$k$Y$-$G$7$g$&$+!#$=$l$H$be(B x e$B$O5a$a$kM-8z7e?t$Ne(B sin
e$B$N7W;;e(B
e$B$K$OM-8z7e?t$,B-$j$J$$$N$GNc30$K$9$k$Y$-$G$7$g$&$+!#e(B

e$B$H$b$+$/e(B BigDecimal e$B$Ne(B mod, divMod
e$B$K4X$7$F$O$^$:0UL#$r7h$a$ke(B
[email protected]$H;W$$$^$9!#e(BInt, Float [email protected]$r9M$($k$He(B mod,
divMod
e$B$H$$$&%a%=%C%I$ODj5A$9$Y$-$G$J$$$N$+$b$7$l$^$;$s!#e(B

e$BK-J!$G$9!#e(B

Mathematica e$B$G$O<!$N$h$&$K$J$j$^$9!#e(B
In[1]:= N[Sin[N[100000000, 1]], 100]
Out[1]= 0.

e$B$3$l$O$I$&$$$&7W;;7k2L$K$h$ke(B 0. e$B$G$7$g$&$+!#e(B
e$B7W;;$G$-$J$$$H$$$&0UL#$Ne(B 0.e$B!)e(B
Sin e$B$G$J$/e(B Exp [email protected]$H$I$&$$$&7k2L$rJV$9$N$G$7$g$&!#e(B

In[2]:= Mod[N[100000000, 1], 3]
Out[2]= 0.*10^7

e$B$3$&$$$&e(B mod e$B$OI,[email protected]$H;W$$$^$9$7$3$l$re(B divMod
e$B$NM>$j$H$9$k$N$be(B
e$B$"$j$=$&$K;W$$$^$9$,$3$l$re(B %
e$B$K$7$?J}$,$h$$$G$7$g$&$+!#$=$l$H$be(B
e$B$7$J$$J}$,$h$$$G$7$g$&$+!#e(B

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

On 2010/02/08, at 19:36, TOYOFUKU Chikanobu wrote:

e$BK-J!$G$9!#e(B

Mathematica e$B$G$O<!$N$h$&$K$J$j$^$9!#e(B
In[1]:= N[Sin[N[100000000, 1]], 100]
Out[1]= 0.

e$B$3$l$O$I$&$$$&7W;;7k2L$K$h$ke(B 0. e$B$G$7$g$&$+!#e(B
e$B7W;;$G$-$J$$$H$$$&0UL#$Ne(B 0.e$B!)e(B

e$B$=$&$G$O$J$/!"M-8z7e?te(B1e$B$G7W;;$9$k$He(B 0. e$B$K$J$k$H$$$&!"e(B
e$B$=$N$^$^$N0UL#[email protected]$H;W$$$^$9!#e(B
e$B$=$b$=$be(B Sin e$B$N30B&$Ne(B N e$B$OITMW$G$7$?e(B

In[15]:= Sin[N[100000000, 1]]
Out[15]= 0.

Sin e$B$N%"%k%4%j%:%`$K$h$C$F$O$3$&$J$i$J$$$h$&$Ke(B
e$B$G$-$k$N$+$b$7$l$^$;$s!#e(B

Sin e$B$G$J$/e(B Exp [email protected]$H$I$&$$$&7k2L$rJV$9$N$G$7$g$&!#e(B

In[17]:= Exp[N[100000000, 1]]
Out[17]= 0.*10^43429455

In[2]:= Mod[N[100000000, 1], 3]
Out[2]= 0.*10^7

e$B$3$&$$$&e(B mod e$B$OI,[email protected]$H;W$$$^$9$7$3$l$re(B divMod e$B$NM>$j$H$9$k$N$be(B
e$B$"$j$=$&$K;W$$$^$9$,$3$l$re(B % e$B$K$7$?J}$,$h$$$G$7$g$&$+!#$=$l$H$be(B
e$B$7$J$$J}$,$h$$$G$7$g$&$+!#e(B

% e$B1i;;;R$KBP1~$5$;$k$+$I$&$+$K$D$$$F$O!"$H$F$bG:$_$I$3$m$G$9$M!#e(B
e$B0l4S$7$Fe(B % e$B$Oe(B mod
e$B$NJLL>$H$7$F$7$^$&$N$b%"%[email protected]$H;W$$$^$9!#e(B
e$B$=$&$7$J$$$HDj$a$k;v$b4V0c$$$G$O$J$$$H;W$$$^$9$,!"e(B
e$B$=$N>l9g$I$N$h$&$J1i;;$K$J$k$+2~$a$FDj5A$,I,MW$G$9$M!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

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/

2010e$BG/e(B2e$B7ne(B7e$BF|e(B22:04 TOYOFUKU Chikanobu
[email protected]:

  • e$B=|?te(B > 0 e$B"Me(B 0 <= e$B>jM>e(B < e$B=|?te(B

?e$B;d$b$3$NA0e(B mod e$B$K!V>jM>e(B < e$B=|?t!W$r4|BT$9$k$H=q$-$^$7$?$,2~$a$Fe(B
e$B9M$($?$i!“Nc$($Pe(B
(e$BM-8z7e?t#17e$G#12/e(B).mod(e$B!JM-8z7e?t$$$/$D$G$”$m$&$,!Ke(B3)
e$B$K$O0UL#$N$"$kCM$H$7$F2?$r4|BT$9$Y$-$G$7$g$&$+!#e(B

bigdecimal e$B$N85%M%?$C$]$$e(B Java e$B$Ne(B BigDecimal
e$B$G;n$7$F$_$^$7$?!#e(B

precision 1 e$B$Ne(B 1E50 e$B$H!"e(Bprecision 1 e$B$Ne(B 3 e$B$Ne(B
divideAndRemainder e$B$Oe(B
precision 50 e$B$Ne(B 3333…333 e$B$H!"e(Bprecision 1 e$B$Ne(B 1
e$B$rJV$9$h$&$G$9!#e(B
precision e$B$C$F$$$o$f$k!VM-8z?t;z!W$8$c$J$$$_$?$$$J$s$G$9$h$M!#e(B
e$B$h$/$o$+$i$J$$!#e(B

v1: 1E+50(1)
v2: 3(1)
v1/v2: 33333333333333333333333333333333333333333333333333(50)
v1%v2: 1(1)

import java.math.BigDecimal
object T {
def p(s: String, v: BigDecimal) {
println(s + v + “(” + v.precision() + “)”)
}
def main(args: Array[String]) {
val v1 = new BigDecimal(“1E50”)
val v2 = new BigDecimal(“3”)
val a = v1 divideAndRemainder v2
p("v1: ", v1)
p("v2: ", v2)
p("v1/v2: ", a(0))
p("v1%v2: ", a(1))
}
}

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

On 2010/02/08, at 23:55, Yusuke ENDOH wrote:

precision 1 e$B$Ne(B 1E50 e$B$H!"e(Bprecision 1 e$B$Ne(B 3 e$B$Ne(B divideAndRemainder e$B$Oe(B
precision 50 e$B$Ne(B 3333…333 e$B$H!"e(Bprecision 1 e$B$Ne(B 1 e$B$rJV$9$h$&$G$9!#e(B
precision e$B$C$F$$$o$f$k!VM-8z?t;z!W$8$c$J$$$_$?$$$J$s$G$9$h$M!#e(B
e$B$h$/$o$+$i$J$$!#e(B

http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/math/BigDecimal.html
e$B$h$je(B

““BigDecimal
e$B%/%i%9$O!”%f!<%6$,4]$aF0:[email protected])8f$G$-$k$h$&$K$7$^$9!#4]$a%b!<%I$,;XDj$5$l$:!”@53N$J7k2L$,I=8=$G$-$J$$>l9g!“Nc30$,%9%m!<$5$l$^$9!#e(B”"
““e$B$9$Y$F$N;;=Q1i;;;R$G$O!“1i;;$O!”$^$:@53N$JCf4V7k2L$r7W;;$7!”<!$KA*Br$5$l$?4]$a%b!<%I$r;HMQ$7$Fe(B
(e$BI,MW$J>l9g$Oe(B)
[email protected]:[email protected]_Dj$G;XDj$5$l$?7e?t$K4]$a$k$H$$$&<j=g$G<B9T$5$l$^$9!#e(B”"

e$B$H$$$&[email protected]$=$&$J$N$G!"@53N$K7W;;$5$l$?7k2L$,4]$a$i$l$:$KJV$C$F$-$?$s$G$7$g$&$+$M!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

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

irc [email protected]$5$;$FD:$$$F!"BgJQ;29M$K$J$j$^$7$?!#e(B

BigDecimal
e$B$K$OM-8z7e?t$,[email protected]$JJ,Ln$H$=$&$G$J$$J,Ln$NFs<oN`$NMQES$,$"$j$^$9!#e(B
e$BA0<T$N>l9g!"M-8z7e?t$,<+J,$N7W;;@:EY$rCN$C$F$$$F$/$l$?$[$&$,M-$jFq$$$H;W$$$^$9!#e(B
e$B$+$H$$$C$F!"e(BMathematica
e$B$N$h$&$K1i;;[email protected]$C$F$7$^$&$H!"e(B
BigDecimal
[email protected]$NB?G\D9IbF0>[email protected]?t$H$7$F;H$C$F$$$k?M$K$O;H$($J$$BeJ*$K$J$C$F$7$^$$$^$9!#e(B

e$B$I$&$7$?$i$h$$$+9M$($F$_$?$N$G$9$,!"1i;;7k2L$O>[email protected][email protected]$JCM$r;;=P$9$k$h$&$K$7!"e(B
e$B%%Z%i%s%I$+$i7Q>[email protected]$H$7$FJ];}$5$;!"[email protected]$j$?$$?M$Oe(B
BigDecimal#rounnd [email protected]<(E
$K4]$a$F$b$i$$$^$7$g$&$+!#e(B

BigDecimal e$B$OI,$:M-8B$NM-8z7e?t$r;}$D$3$H$K$7$F!"e(B
[email protected]:EY$NCM$Oe(B Integer e$B$He(B Rational
e$B$GI=8=$5$;$k$h$&$K$7$^$9!#e(B
BigDecimal e$B$rAH$9~$?tCM%/%i%9$H0l=o$K;H$($k$h$&$Ke(B
e$B<[email protected]$,I,[email protected]$H;W$$$^$9$,!"e(BRational e$B$,AH$9~$$K$J$C$?e(B
e$B:#$Ne(B Ruby e$B$G$O$3$NJ}K!$,NI$$$N$G$O$J$$$+$H9M$($^$7$?!#e(B

On 2010/02/08, at 23:51, Kenta M. wrote:

e$B$3$l$O$I$&$$$&7W;;7k2L$K$h$ke(B 0. e$B$G$7$g$&$+!#e(B
e$B$G$-$k$N$+$b$7$l$^$;$s!#e(B
e$B$"$j$=$&$K;W$$$^$9$,$3$l$re(B % e$B$K$7$?J}$,$h$$$G$7$g$&$+!#$=$l$H$be(B
e$B$7$J$$J}$,$h$$$G$7$g$&$+!#e(B

% e$B1i;;;R$KBP1~$5$;$k$+$I$&$+$K$D$$$F$O!"$H$F$bG:$_$I$3$m$G$9$M!#e(B
e$B0l4S$7$Fe(B % e$B$Oe(B mod e$B$NJLL>$H$7$F$7$^$&$N$b%"%[email protected]$H;W$$$^$9!#e(B
e$B$=$&$7$J$$$HDj$a$k;v$b4V0c$$$G$O$J$$$H;W$$$^$9$,!"e(B
e$B$=$N>l9g$I$N$h$&$J1i;;$K$J$k$+2~$a$FDj5A$,I,MW$G$9$M!#e(B


Kenta M.
OpenPGP FP = FA26 35D7 4F98 3498 0810 E0D5 F213 966F E9EB 0BCC

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$BK-J!$G$9!#e(B

In[17]:= Exp[N[100000000, 1]]
Out[17]= 0.*10^43429455

0.* e$B$H$$$&$N$,5a$a$kM-8z7e?t$K1~$($i$l$J$$$H$$$&$3$H$G$9$+$M!#e(B
e$B8+2a$4$7$F$^$7$?$,e(B

In[2]:= Mod[N[100000000, 1], 3]
Out[2]= 0.*10^7

e$B$3$A$i$be(B 0.* e$B$G$7$?$+!#e(B

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/5776
e$B$K$4$H$1$s$5$s$K$h$ke(B Mathematica
[email protected]:EY$N<h$j07$$$K4X$9$ke(B
e$BJs9p$,$"$j$^$9$M!#$=$s$JOC$,$"$C$?$3$H$9$C$+$jK:$l$F$^$7$?!#e(B

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

2010e$BG/e(B2e$B7ne(B8e$BF|e(B8:51 wanabe [email protected]:

e$B$3$l$O$d$O$j%P%[email protected]$H;W$$$^$9!#e(B
e$B!JCfN,!Ke(B
e$B$h$C$F$3$N%Q%C%A$O$"$F$k$Y$-$G$9!#e(Brubyspec e$B$N%(%i!<$b>C$($^$9!#e(B

e$B%o%J%Y$5$s!"$*4j$$$7$F$$$$$G$7$g$&$+!#e(B

e$BBgJQ?=$7Lu$"$j$^$;$s!#e(B
e$B>p$1$J$$OC$J$N$G$9$,!"%Q%C%A$N0UL#$r3P$($F$*$i$:H=CG$G$-$+$M$^$9!#e(B

e$B<B$Oe(B 1 e$BG/H>A0$N%a!<%[email protected]$H5$$,$D$+$:$KJV?.$7$?$N$OHkL)$G$9!#e(B

[email protected]$r8+$k$H!"5?Ld$NM>CO$N$J$$%P%0$G$O$J$/0UL#[email protected]!&;EMM$KF’$_9~$`$h$&$G$9$N$Ge(B
e$B%a%s%F%J$^$?$O$^$D$b$H$5$s$N7hDj$,I,MW$G$O$J$$$+$H;W$$$^$9!#e(B

e$B$=$N$h$&$G$9$M!#[email protected]!“8=:_$Ne(B bigdecimal
e$B$O:[email protected][email protected]$9$He(B
e$B%-%j$,$J$$$N$G!”$H$j$"$($:$Oe(B rubyspec
e$B$r%Q%9$5$;$?$$$H;W$$$^$9!#e(B

e$B:n<TK?M$G$"$k>.NS$5$s$N%Q%C%Ae(B [ruby-dev:40358]
e$B$,NI$5$=$&$J$N$G!"e(B
e$B$3$A$i$r%3%%C%H$5$;$FD:$-$^$9!#$`$i$?$5$s$,%3%%C%?="G$$7$?$i9%$-e(B
e$B$J$h$&$K$7$F$/[email protected]$5$$!#e(B

e$B8D?ME*[email protected]$&$H!“e(Bbigdecimal
[email protected]$rJ]$A$J$,$i2~A1$7$F$$$/e(B
e$B$N$,:[email protected]$H;W$$$^$9!#2<<j$K!V2~A1!W$7$Fe(B Rails
e$B$”$?$j$r7bDF$7$Fe(B
e$B$7$^$&$h$j$O!"e(Bbigdecimal e$B$O%P%0$b4^$a$FE`7k$7$F$7$^$$!"e(B1.9.3
e$B0J9_e(B
e$B$Ge(B alternative e$B$rF3F~!“e(B2.0 e$B$Ge(B gem
e$B2=$9$k!”$H$$$&7W2h$,$$$$$N$G$Oe(B
e$B$J$$$+$H;W$C$F$^$9!#8D?ME*$J0U8+$G$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