[Bug #793] BigDecimal('Infinity').to_r $B$,Nm$K$J$k(B

Bug #793: BigDecimal(‘Infinity’).to_r e$B$,Nm$K$J$ke(B
http://redmine.ruby-lang.org/issues/show/793

e$B5/I<<Te(B: tadayoshi funaba
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal

$ ./ruby -rbigdecimal -e “p BigDecimal(‘Infinity’).to_r”
(0/1)

1.8 e$B$G$bF1$8$G$9!#e(B

$ ruby18 -rbigdecimal -rbigdecimal/util -rrational -e “p
BigDecimal(‘Infinity’).to_r”
Rational(0, 1)

e$B0JA0!"?V$M$?$H;W$&$N$G$9$,!“e(Bto_i e$B$,e(B nil
e$B$K$J$k$N$bLdBj$,$”$k$H;W$$$^$9!#e(B

$ ./ruby -rbigdecimal -e “p BigDecimal(‘Infinity’).to_i”
nil

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

In message “Re: [ruby-dev:37187] [Bug #793] BigDecimal(‘Infinity’).to_r
e$B$,Nm$K$J$ke(B”
on Tue, 25 Nov 2008 23:29:59 +0900, tadayoshi funaba
[email protected] writes:

|$ ./ruby -rbigdecimal -e “p BigDecimal(‘Infinity’).to_r”
|(0/1)

|e$B0JA0!"?V$M$?$H;W$&$N$G$9$,!“e(Bto_i e$B$,e(B nil e$B$K$J$k$N$bLdBj$,$”$k$H;W$$$^$9!#e(B
|
|$ ./ruby -rbigdecimal -e “p BigDecimal(‘Infinity’).to_i”
|nil

e$B$I$&$be(BBigDecimale$B$N;EMM$r8+$F$k$He(B

e$B$H$$$&0U;W$,$"$k$h$&$G$9!#8D?ME*$K$O%0%m!<%P%k$J>uBV$b!"$^$:e(B
e$B$$>u67$G$bNc30$r5/$3$5$:7QB3$9$k$N$b!"$"$^$jNI$/[email protected]_7W$G$Oe(B
e$B$J$$$+$H46$8$J$$$G$b$J$$$G$9!#e(B

[email protected]!“e(BBigDecimale$B$GJD$8$F$k$&$A$O$&$l$7$$$3$H$b$”$k$N$+$b$7$le(B
e$B$J$$$N$G!"!Ve([email protected]$3&!W$KF~$C$F$/$ke(Bto_[email protected]<(E$KNc30$rH/e(B
[email protected]$5$;$k$3$H$K$7$^$9!#e(B

e$B$^$"!"?t3XCN$i$:$N;d$NH=CG$G$9$+$i!“[email protected]$O$$$De(B
e$B$b9b$$$N$G$9$,!”$=$N>l9g$O$I$J$?$+;XE&$7$F$/[email protected]$5$$!#e(B

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

e$B$I$&$be(BBigDecimale$B$N;EMM$r8+$F$k$He(B

e$B$=$N%b!<%I$Ge(B EXCEPTION_ZERODIVIDE e$B$rM-8z$K$9$k$He(B Infinity
e$B<+BN$r:n$l$Je(B
e$B$/$J$k$s$G$9$M!#Nm3d$Ge(B Infinity [email protected]$8$k$N$H!"e(BInfinity
e$B$r:n$k$3$H$OJL$Ne(B
e$B$h$&$K;W$&$N$G$9$,!"e(BMarshal.load
e$B$b=PMh$J$/$J$j$^$9$M!#$3$&$$$&$b$N$J$Ne(B
e$B$+$J!#e(B

$ ./irb-test -rbigdecimal
[email protected]> b = BigDecimal(‘Infinity’)
#=> #BigDecimal:827a9a4,‘Infinity’,4(4)
[email protected]>
BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE,true)
#=> 1
[email protected]> BigDecimal(‘Infinity’)
FloatDomainError: Computation results to ‘Infinity’
from (irb):3:in BigDecimal' from (irb):3 from ./bin/irb:12:in
[email protected]> Marshal.load(Marshal.dump(b))
FloatDomainError: Computation results to ‘Infinity’
from (irb):5:in _load' from (irb):5:inload’
from (irb):5
from ./bin/irb:12:in `’

EXCEPTION_ZERODIVIDE(e$B$He(BEXCEPTION_OVERFLOW)e$B$,!"$I$&$$$&[email protected](B
e$B$+e(BEXCEPTION_INFINITYe$B$NJLL>$K$J$C$F$^$9$M!#K\Mh$O;H$$J,$1$k$Ye(B
[email protected]$H;W$&$N$G$9$,!#e(B

e$B$"$"!"$J$k$[$I!#85$N;[email protected]$He(B BigDecimal(‘Infinity’).to_i
e$B$GNc30$r>e$2$ke(B
e$B$K$Oe(B EXCEPTION_INFINITY
[email protected]_Dj$7$J$1$l$P$J$i$J$$!"$G$b!"$=$&$9$k$He(B
BigDecimal(‘Infinity’) e$B<+BN$GNc30$H$J$C$F$7$^$&$o$1$G$9$M!#e(B

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

In message “Re: [ruby-dev:37204] Re: [Bug #793]
BigDecimal(‘Infinity’).to_r e$B$,Nm$K$J$ke(B”
on Wed, 26 Nov 2008 22:01:52 +0900, Tadayoshi F.
[email protected] writes:

|e$B$=$N%b!<%I$Ge(B EXCEPTION_ZERODIVIDE e$B$rM-8z$K$9$k$He(B Infinity e$B<+BN$r:n$l$Je(B
|e$B$/$J$k$s$G$9$M!#Nm3d$Ge(B Infinity [email protected]$8$k$N$H!"e(BInfinity e$B$r:n$k$3$H$OJL$Ne(B
|e$B$h$&$K;W$&$N$G$9$,!"e(BMarshal.load e$B$b=PMh$J$/$J$j$^$9$M!#$3$&$$$&$b$N$J$Ne(B
|e$B$+$J!#e(B

EXCEPTION_ZERODIVIDE(e$B$He(BEXCEPTION_OVERFLOW)e$B$,!"$I$&$$$&[email protected](B
e$B$+e(BEXCEPTION_INFINITYe$B$NJLL>$K$J$C$F$^$9$M!#K\Mh$O;H$$J,$1$k$Ye(B
[email protected]$H;W$&$N$G$9$,!#e(B

EXCEPTION_ZERODIVIDE [email protected]_Dj$7$?>l9g!"e(BBigDecimal#/
e$B$GNc30$K$J$j$^$9e(B
e$B$,!"e(Bdiv e$B$de(B divmod e$B$G$O$J$j$^$;$s!#e(BFloat
e$B$G$b!"e(Bdiv e$B$ONc30$G$9$,!"e(B
divmod e$B$G$ONc30$K$J$j$^$;$s!#e(BInteger e$B$G$O!"e(Bdive$B!"e(Bdivmod
e$B$H$b$KNc30e(B
e$B$K$J$j$^$9!#e(B

e$B0c$$$,$"$j$^$9$,!"$3$N$"$?$j$I$&$J$s$G$7$g$&!#$=$l$>$l$K$D$$$Fe(B
divmod
e$B$He(B modulo e$B$N4X78$K$OL7=b$O$J$$$h$&$G$9!#e(B

$ ./irb-test -rbigdecimal
[email protected]>
BigDecimal::mode(BigDecimal::EXCEPTION_ZERODIVIDE,true)
#=> 16
[email protected]> BigDecimal(‘1’) / 0
FloatDomainError: (VpDivd) Divide by zero
from (irb):2:in /' from (irb):2 from ./bin/irb:12:in
[email protected]> BigDecimal(‘1’).div(0)
#=> #BigDecimal:826d998,‘NaN’,4(4)
[email protected]> BigDecimal(‘1’).divmod(0)
#=> [#BigDecimal:82259e0,‘NaN’,4(4), #BigDecimal:8225a58,‘NaN’,4(4)]

[email protected]> 1.0.div(0)
ZeroDivisionError: divided by 0
from (irb):5:in div' from (irb):5 from ./bin/irb:12:in
[email protected]> 1.0.divmod(0)
#=> [NaN, NaN]

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