Bug #5098

bigdecimal/util.rb で定義される to_d メソッドによる型変換と、BigDecimal 関数による型変換が整合していない

Added by Kenta Murata over 2 years ago. Updated over 2 years ago.

[ruby-dev:44241]
Status:Closed
Priority:Normal
Assignee:Kenta Murata
Category:ext
Target version:1.9.3
ruby -v:ruby 1.9.4dev (2011-07-17 trunk 32564) [x86_64-darwin10.8.0] Backport:

Description

BigDecimal() および BigDecimal#coerce との関係より、以下のように修正が必要。

  • Float#to_d はオプショナルな精度を受け付けるように変更し、精度が省略された場合は Float::DIG が指定されたものとする。
  • Rational#to_d は精度を必須とする。
  • Integer#to_d を追加する。

Associated revisions

Revision 32677
Added by Kenta Murata over 2 years ago

  • ext/bigdecimal/lib/bigdecimal/util.rb (Integer#to_d): added for symmetry to BigDecimal() function with an Integer. fixes #5098.
  • test/bigdecimal/testbigdecimalutil.rb: add test for the above change.

Revision 32679
Added by Kenta Murata over 2 years ago

  • ext/bigdecimal/lib/bigdecimal/util.rb (Float#to_d): modified for specifying precision. fixes #5098.
  • test/bigdecimal/testbigdecimalutil.rb: add test for the above change.

Revision 32680
Added by Kenta Murata over 2 years ago

  • ext/bigdecimal/lib/bigdecimal/util.rb (Rational#to_d): zero or negative precision is error. fixes #5098.
  • test/bigdecimal/testbigdecimalutil.rb: add test for the above change.

History

#1 Updated by Kenta Murata over 2 years ago

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

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


  • ext/bigdecimal/lib/bigdecimal/util.rb (Integer#to_d): added for symmetry to BigDecimal() function with an Integer. fixes #5098.
  • test/bigdecimal/testbigdecimalutil.rb: add test for the above change.

Also available in: Atom PDF