Project

General

Profile

Actions

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.

Status:
Closed
[ruby-core:<unknown>]

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)

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0