Backport #8958
closed
Rational#to_d don't match documentation
Added by ejfinneran (E.J. Finneran) over 10 years ago.
Updated over 10 years ago.
Description
The documentation states that Rational#to_d (added by BigDecimal) has an optional parameter to limit the precision. However, that parameter is not optional as implemented.
http://www.ruby-doc.org/stdlib-2.0.0/libdoc/bigdecimal/rdoc/Rational.html
╰─○ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.5.0]
╰─○ irb
2.0.0p247 :001 > require 'bigdecimal'
=> true
2.0.0p247 :002 > require 'bigdecimal/util'
=> true
2.0.0p247 :003 > 3.to_r.to_d
ArgumentError: wrong number of arguments (0 for 1)
from /Users/ej/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/bigdecimal/util.rb:98:in to_d' from (irb):3 from /Users/ej/.rvm/rubies/ruby-2.0.0-p247/bin/irb:16:in
'
2.0.0p247 :004 > 3.to_r.to_d(1)
=> #BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)
- Status changed from Open to Assigned
Still looking into this one E.J. thanks for your patience.
I think this is a bug of Rational#to_d. I'll fix it.
@mrkn (Kenta Murata) I'm not sure it would make sense to have a default precision here... Is there a default precision anywhere in the BigDecimal library?
@marcandre (Marc-Andre Lafortune) Yes. We cannot determine a default precision for a rational number generally. I think I confused when I replied #3.
So this issue can be closed.
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r43669.
E.J., thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- ext/bigdecimal/lib/bigdecimal/util.rb: [DOC] Document the required
+precision+ argument for Rational#to_d [Bug #8958]
-This line, and those below, will be ignored--
M ChangeLog
M ext/bigdecimal/lib/bigdecimal/util.rb
- Status changed from Closed to Assigned
- Backport set to 1.9.3: DONTNEED, 2.0.0: REQUIRED
Hi,
There are still examples of Rational#to_d without arguments in documentation at call-seq section and sample code.
- Assignee changed from zzak (zzak _) to nagachika (Tomoyuki Chikanaga)
- Status changed from Assigned to Closed
This issue was solved with changeset r43678.
E.J., thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- ext/bigdecimal/lib/bigdecimal/util.rb: [DOC] remove example of
Rational#to_d without argument. [Bug #8958]
- Tracker changed from Bug to Backport
- Project changed from Ruby master to Backport200
- Category deleted (
doc)
- Status changed from Closed to Assigned
- Status changed from Assigned to Closed
This issue was solved with changeset r44314.
E.J., thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
merge revision(s) 43669,43672,43678: [Backport #8958]
* ext/bigdecimal/lib/bigdecimal/util.rb: [DOC] Document the required
+precision+ argument for Rational#to_d [Bug #8958]
* ext/bigdecimal/lib/bigdecimal/util.rb: [DOC] +precision+ is required
* ext/bigdecimal/lib/bigdecimal/util.rb: [DOC] remove example of
Rational#to_d without argument. [Bug #8958]
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0