Project

General

Profile

Bug #5736

Numeric#quo should convert with #to_r

Added by john_firebaugh (John Firebaugh) over 5 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
Backport:
[ruby-core:41575]

Description

Numeric#quo currently constructs a Rational with self as the raw numerator, doing no coercion, before dividing. Instead it should follow the same pattern as Numeric#{numerator,denominator}, and convert self with #to_r. This allows any Numeric subclass to participate in the type conversion.

Associated revisions

Revision 41109
Added by mrkn (Kenta Murata) about 4 years ago

* numeric.c (num_quo): Use to_r method to convert the receiver to
rational. [Bug #5736]

* test/ruby/test_numeric.rb: add a test for the above change.

Revision 41109
Added by mrkn (Kenta Murata) about 4 years ago

* numeric.c (num_quo): Use to_r method to convert the receiver to
rational. [Bug #5736]

* test/ruby/test_numeric.rb: add a test for the above change.

Revision 41109
Added by mrkn (Kenta Murata) about 4 years ago

* numeric.c (num_quo): Use to_r method to convert the receiver to
rational. [Bug #5736]

* test/ruby/test_numeric.rb: add a test for the above change.

Revision 41109
Added by mrkn (Kenta Murata) about 4 years ago

* numeric.c (num_quo): Use to_r method to convert the receiver to
rational. [Bug #5736]

* test/ruby/test_numeric.rb: add a test for the above change.

Revision 41132
Added by mrkn (Kenta Murata) about 4 years ago

* rational.c (numeric_quo): move num_quo in numeric.c to numeric_quo
in rational.c to refer canonicalization state for mathn support.
[Bug #5736]

* numeric.c (num_quo): ditto.

* test/test_mathn.rb: add a test for the change at r41109.

Revision 41132
Added by mrkn (Kenta Murata) about 4 years ago

* rational.c (numeric_quo): move num_quo in numeric.c to numeric_quo
in rational.c to refer canonicalization state for mathn support.
[Bug #5736]

* numeric.c (num_quo): ditto.

* test/test_mathn.rb: add a test for the change at r41109.

Revision 41132
Added by mrkn (Kenta Murata) about 4 years ago

* rational.c (numeric_quo): move num_quo in numeric.c to numeric_quo
in rational.c to refer canonicalization state for mathn support.
[Bug #5736]

* numeric.c (num_quo): ditto.

* test/test_mathn.rb: add a test for the change at r41109.

Revision 41132
Added by mrkn (Kenta Murata) about 4 years ago

* rational.c (numeric_quo): move num_quo in numeric.c to numeric_quo
in rational.c to refer canonicalization state for mathn support.
[Bug #5736]

* numeric.c (num_quo): ditto.

* test/test_mathn.rb: add a test for the change at r41109.

History

#2 Updated by ko1 (Koichi Sasada) over 5 years ago

  • Assignee set to mrkn (Kenta Murata)

#3 Updated by shyouhei (Shyouhei Urabe) over 5 years ago

  • Status changed from Open to Assigned

#4 Updated by mrkn (Kenta Murata) about 4 years ago

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

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


  • numeric.c (num_quo): Use to_r method to convert the receiver to
    rational. [Bug #5736]

  • test/ruby/test_numeric.rb: add a test for the above change.

Also available in: Atom PDF