Issue #1454 has been updated by shyouhei (Shyouhei Urabe).

Description updated
Status changed from Open to Closed

This issue no longer seen in 2.0.0.  If you still experience difficulties, please reopen.
----------------------------------------
Bug #1454: compatability of rational and bigdecimal (1.8 and 1.9)
https://bugs.ruby-lang.org/issues/1454#change-43031

Author: bk1 (Karl Brodowsky)
Status: Closed
Priority: Normal
Assignee: 
Category: core
Target version: Ruby 1.8.8
ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i586-linux]


=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 b*a yield a similar error
 a+b, a-b, a*b 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 `<main>'
=end



-- 
http://bugs.ruby-lang.org/