Forum: Ruby-core [ruby-trunk - Bug #8958][Open] Rational#to_d don't match documentation

25e89616e26a156aadd75313aa7b1e4c?d=identicon&s=25 Ej Finneran (ejfinneran)
on 2013-09-26 21:19
(Received via mailing list)
Issue #8958 has been reported by ejfinneran (E.J. Finneran).

----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958

Author: ejfinneran (E.J. Finneran)
Status: Open
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport:


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
054b5f6b8afdd5f6190bad08e46cd782?d=identicon&s=25 zzak (Zachary Scott) (Guest)
on 2013-09-26 23:13
(Received via mailing list)
Issue #8958 has been updated by zzak (Zachary Scott).

Status changed from Open to Assigned

It seems the documentation is wrong, the implementation is a required
argument:
https://github.com/ruby/ruby/blob/trunk/ext/bigdec...

I have asked for feedback from murata-san to confirm this spec in
BigDecimal.

Thank you for finding this bug!
----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958#change-42021

Author: ejfinneran (E.J. Finneran)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport:


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
054b5f6b8afdd5f6190bad08e46cd782?d=identicon&s=25 zzak (Zachary Scott) (Guest)
on 2013-10-15 17:08
(Received via mailing list)
Issue #8958 has been updated by zzak (Zachary Scott).


Still looking into this one E.J. thanks for your patience.
----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958#change-42472

Author: ejfinneran (E.J. Finneran)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport:


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
7cca11c5257fda526eeb4b1ada28f904?d=identicon&s=25 mrkn (Kenta Murata) (Guest)
on 2013-10-17 18:04
(Received via mailing list)
Issue #8958 has been updated by mrkn (Kenta Murata).


I think this is a bug of Rational#to_d.  I'll fix it.
----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958#change-42506

Author: ejfinneran (E.J. Finneran)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport:


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
0e610136db92027148906c92d57fdb36?d=identicon&s=25 marcandre (Marc-Andre Lafortune) (Guest)
on 2013-11-10 17:43
(Received via mailing list)
Issue #8958 has been updated by marcandre (Marc-Andre Lafortune).


@mrkn  I'm not sure it would make sense to have a default precision
here... Is there a default precision anywhere in the BigDecimal library?
----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958#change-42846

Author: ejfinneran (E.J. Finneran)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport:


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
7cca11c5257fda526eeb4b1ada28f904?d=identicon&s=25 mrkn (Kenta Murata) (Guest)
on 2013-11-13 10:56
(Received via mailing list)
Issue #8958 has been updated by mrkn (Kenta Murata).


@marcandre 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.
----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958#change-42900

Author: ejfinneran (E.J. Finneran)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport:


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
5cf8f058a4c094bb708174fb43e7a387?d=identicon&s=25 nagachika (Tomoyuki Chikanaga) (Guest)
on 2013-11-13 15:13
(Received via mailing list)
Issue #8958 has been updated by nagachika (Tomoyuki Chikanaga).

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.
----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958#change-42905

Author: ejfinneran (E.J. Finneran)
Status: Assigned
Priority: Normal
Assignee: zzak (Zachary Scott)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport: 1.9.3: DONTNEED, 2.0.0: REQUIRED


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
054b5f6b8afdd5f6190bad08e46cd782?d=identicon&s=25 zzak (Zachary Scott) (Guest)
on 2013-11-13 17:59
(Received via mailing list)
Issue #8958 has been updated by zzak (Zachary Scott).

Assignee changed from zzak (Zachary Scott) to nagachika (Tomoyuki
Chikanaga)

@nagachika good catch, i removed the incorrect call-seq in r43672:
https://github.com/ruby/ruby/commit/62d3853

I will assign it to you for backporting, thanks!
----------------------------------------
Bug #8958: Rational#to_d don't match documentation
https://bugs.ruby-lang.org/issues/8958#change-42909

Author: ejfinneran (E.J. Finneran)
Status: Assigned
Priority: Normal
Assignee: nagachika (Tomoyuki Chikanaga)
Category: doc
Target version:
ruby -v: ruby 2.0.0p247 (2013-06-27 revision 41674)
[x86_64-darwin12.5.0]
Backport: 1.9.3: DONTNEED, 2.0.0: REQUIRED


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/bigdec...

╰─○ 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 `<main>'
2.0.0p247 :004 > 3.to_r.to_d(1)
 => #<BigDecimal:7ffc8c8afaa8,'0.3E1',9(36)>
This topic is locked and can not be replied to.