Bug #1454
closedcompatability of rational and bigdecimal (1.8 and 1.9)
Description
=begin
I did the following to produce this error:
ruby 1.8¶
require "rational"
require "bigdecimal"
a=BigDecimal("3.2")
b=Rational(3,4)
b/a
---> TypeError: Rational can't be coerced into BigDecimal
from /usr/lib/ruby/1.8/rational.rb:206:in coerce' from /usr/lib/ruby/1.8/rational.rb:206:in
/'
from (irb):14
b+a, b-a and ba yield a similar error
a+b, a-b, ab and a/b work fine.
$ irb --version
--> irb 0.9.5(05/04/13)
$ ruby --version
--> ruby 1.8.7 (2008-08-11 patchlevel 72) [i586-linux]
jruby 1.2¶
jruby does seem to have this issue:
$ jruby --version
--> jruby 1.2.0 (ruby 1.8.6 patchlevel 287) (2009-03-16 rev 9419) [i386-java]
$ jirb --version
--> irb 0.9.5(05/04/13)
[code above in jirb]
--> TypeError: Rational can't be coerced into BigDecimal
from /usr/local/lib/jruby/lib/ruby/1.8/rational.rb:206:in `/'
from (irb):6
ruby 1.9¶
$ ruby --version
--> ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
$ irb --version
--> irb 0.9.5(05/04/13)
[above code in irb]
--> TypeError: BigDecimal can't be coerced into Rational
from (irb):5:in /' from (irb):5 from /usr/local/bin/irb:12:in
'
=end
Updated by bk1 (Karl Brodowsky) over 15 years ago
=begin
a similar error occurs when adding BigDecimal and Complex.
=end
Updated by shyouhei (Shyouhei Urabe) about 11 years ago
- Description updated (diff)
- Status changed from Open to Closed
This issue no longer seen in 2.0.0. If you still experience difficulties, please reopen.