Project

General

Profile

Backport #7176

Rational can't be coerced into BigDecimal (TypeError)

Added by aptinio (Aaron Tinio) almost 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:48045]

Description

Rational + BigDecimal makes a BigDecimal as follows:

$ ruby -rbigdecimal -e "puts Rational(1) + BigDecimal.new('1')"
0.2E1

But BigDecimal + Rationl raises a TypeError as follows:

$ ruby -rbigdecimal -e "puts BigDecimal.new('1') + Rational(1)"
-e:1:in +': Rational can't be coerced into BigDecimal (TypeError)
from -e:1:in
'


Related issues

Related to Backport193 - Backport #7404: BigDecimal#add(Float) のみ BigDecimal を返し、他の四則演算では例外になるClosed11/19/2012Actions

Associated revisions

Revision 2e6b5ece
Added by mrkn (Kenta Murata) over 6 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37406 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37406
Added by mrkn (Kenta Murata) over 6 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]

Revision 37406
Added by mrkn (Kenta Murata) over 6 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]

Revision 37406
Added by mrkn (Kenta Murata) over 6 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]

Revision 37406
Added by mrkn (Kenta Murata) over 6 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]

Revision 37406
Added by mrkn (Kenta Murata) over 6 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]

Revision 37406
Added by mrkn (Kenta Murata) over 6 years ago

  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]

Revision 583d9ede
Added by usa (Usaku NAKAMURA) over 6 years ago

merge revision(s) 37406: [Backport #7176]

    * ext/bigdecimal/bigdecimal.c (BigDecimal_add),
      test/bigdecimal/test_bigdecimal.rb:
      need to specify precision for converting Rational and Float.
      [ruby-core:48045] [Bug #7176]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37550
Added by usa (Usaku NAKAMURA) over 6 years ago

merge revision(s) 37406: [Backport #7176]

* ext/bigdecimal/bigdecimal.c (BigDecimal_add),
  test/bigdecimal/test_bigdecimal.rb:
  need to specify precision for converting Rational and Float.
  [ruby-core:48045] [Bug #7176]

History

Updated by aptinio (Aaron Tinio) almost 7 years ago

This is also encountered in ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]

Updated by sorah (Sorah Fukumori) almost 7 years ago

  • Assignee set to mrkn (Kenta Murata)
  • ruby -v changed from ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] to ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]
#3

Updated by mrkn (Kenta Murata) over 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37406.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/bigdecimal/bigdecimal.c (BigDecimal_add), test/bigdecimal/test_bigdecimal.rb: need to specify precision for converting Rational and Float. [ruby-core:48045] [Bug #7176]
#4

Updated by mrkn (Kenta Murata) over 6 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Category deleted (lib)
  • Status changed from Closed to Assigned
  • Assignee changed from mrkn (Kenta Murata) to usa (Usaku NAKAMURA)
  • Target version deleted (1.9.3)

I think this issue may be backported to 1.9.3.

#5

Updated by usa (Usaku NAKAMURA) over 6 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r37550.
Aaron, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 37406: [Backport #7176]

* ext/bigdecimal/bigdecimal.c (BigDecimal_add),
  test/bigdecimal/test_bigdecimal.rb:
  need to specify precision for converting Rational and Float.
  [ruby-core:48045] [Bug #7176]

Also available in: Atom PDF