BigDecimal

e$B$U$J$P$G$9!#e(B

BigDecimal e$B$K$D$$$F;[email protected][email protected]$i$H=q$-$^$9!#e(B

e$B$^$:!"e(Brequire ‘bigdecimal/util’
e$B$9$k$N$,>/$7LLE]$J$s$G$9$,!“K\BN$HJL$Ke(B
e$B$9$k0UL#$O$”$k$N$G$7$g$&$+!#!#$^$?!"e(Brequire ‘bigdecimal/util’
e$B$7$F$b!“e(B
{BigDecimal,Integer,NilClass}#to_d e$B$,$”$j$^$;$s!#e(B

e$B5U$K!“e(Bbigdecimal/util.rb e$B$G!“e(BBigDecimal#to_r
e$B$rDj5A$7$F$$$k$N$O>/$7ITe(B
e$B;W5D$J46$8$b$”$j$^$9!#e(BRational e$B$be(B BigDecimal
e$B$bBPEy$J4X78$K8+$($k$N$G!“e(B
Rational
e$BB&$GDs6!$5$l$F$$$F$b$*$+$7$/$J$$$H;W$$$^$9!#$3$N$h$&$J>l9g$Ke(B
e$B$I$&$9$Y$-$+$N$+!”;X?K$J$I$,$”$l$PCN$j$?$$$G$9!#e(B

[ruby-list:42523]
e$B$NOC$O$h$/$o$+$i$J$+$C$?$N$G$9$,!"$3$l$K4XO"$7$F!“e(B
String#to_d
[email protected]:EY$K$D$$$F2]Bj$H$$$&$N$O$”$k$N$G$7$g$&$+!#$"$k$H$9$l$P!"e(B
[email protected]$K$D$$$FCN$j$?$$$G$9!#e(B

floore$B!"e(Bceile$B!"e(Btruncatee$B!“e(Bround e$B$NCM$,e(B BigDecimal
e$B$K$J$j$^$9!#e(Bdivmod e$B$N$Re(B
e$B$H$DL$NMWAG$b$=$&$G$9!#$3$l$O!“B>$N?tCM%/%i%9$H0[$J$j$^$9$,!”$3$l$K$De(B
e$B$$$Fe(BBigDecimal e$BFCM-$NM}M3$,$”$k$N$G$7$g$&$+!#e(B

BigDecimal#div e$B$N7k2L$be(B BigDecimal
e$B$K$J$j$^$9!#e(BBigDecimal#div e$B$O$U$?$De(B
e$BL$N>JN,2DG=$J0z?t$,$"$j!"$3$N$?$a$K!"B>$N$b$N$H$O0c$&$b$N$K$J$C$F$7$^$Ce(B
e$B$F$$$k$H;W$$$^$9!#e(B

e$BL58BBg$J$I$re(B to_i e$B$9$k$He(B nil e$B$K$J$j$^$9$,!“e(BFloat
e$B$G$ONc30$K$J$j$^$9!#e(B
e$B$3$N0c$$$KM}M3$O$”$k$N$G$7$g$&$+!#e(B

(1.0/0).to_i # FloatDomainError
(1.0/0).to_d.to_i #=> nil

BigDecimal(‘9e’)
e$B$O%(%i!<[email protected]$H;W$$$^$9!#e(BBigDecimal(’’)e$B!"e(B
BigDecimal(’_9’)e$B!"e(BBigDecimal(’–9’)
e$B$J$I$b%(%i!<$K$O$J$j$^$;$s!#e(B

BigDecimal(0)e$B!"e(BBigDecimal(0.0)
e$B$H=q$1$F$b$$$$$h$&$J5$$,$7$^$9!#e(B

ruby 1.9 e$B$G!"e(BBigDecimal(‘1’) == nil
e$B$,%(%i!<$K$J$j$^$9!#e(B!=e$B!"e(B===e$B!"e(Beql?
e$B$bF1$8$G$9!#e(B

bigdecimal/math e$B$K$Oe(B BigMath e$B%b%8%e!<%k$,$"$j$^$9$,!">o$Ke(B
include
BigMath e$B$7$F$/$l$H$$$&$3$H$J$N$+!"e(BBigMath::PI(100)
e$B$N$h$&$K;2>H$G$-$^e(B
e$B$;$s!#e(B

e$B$"$H!"e(BRational e$B$H$OJQ49$dHf3S$O=PMh$^$9$,!“e(BaBigDecimal *
aRational e$B$Je(B
e$B$I$,=PMh$^$;$s$,!”$3$l$O$3$&$$$&$b$N$J$s$G$9$+$M!#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