Project

General

Profile

Bug #1454

compatability of rational and bigdecimal (1.8 and 1.9)

Added by bk1 (Karl Brodowsky) over 9 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 1.8.7 (2008-08-11 patchlevel 72) [i586-linux]
[ruby-core:23415]

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 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
'
=end

History

#1 Updated by bk1 (Karl Brodowsky) over 9 years ago

=begin
a similar error occurs when adding BigDecimal and Complex.
=end

#2 [ruby-core:58434] Updated by shyouhei (Shyouhei Urabe) almost 5 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.

Also available in: Atom PDF