Actions
Bug #12485
closedKernel.Rational raises TypeError though given denominator returns 1 by to_int
Bug #12485:
Kernel.Rational raises TypeError though given denominator returns 1 by to_int
Description
Files
Actions
Added by mrkn (Kenta Murata) about 10 years ago. Updated over 5 years ago.
Description
Files
| rational.c.diff (539 Bytes) rational.c.diff | mrkn (Kenta Murata), 06/13/2016 02:53 PM | ||
| rational-denom-to_int.patch (1.73 KB) rational-denom-to_int.patch | jeremyevans0 (Jeremy Evans), 07/25/2019 03:28 PM |
Attached patch can fix this issue.
You can use RB_INTEGER_TYPE_P in the trunk.
Nobuyoshi Nakada wrote:
You can use
RB_INTEGER_TYPE_Pin the trunk.
I forgot it. Thanks.
I'm not sure if this is considered a bug or not. Rational will already try to convert numerator and denominator via to_r. However, if we do want to convert via to_int if to_r is not defined, the attached patch should implement it.
I'm working on this at https://github.com/ruby/ruby/pull/3684
Applied in changeset git|d23d5c3130a0944e7e591370cbf8599009318a7c.
rational.c: try converting by to_int in Rational() (#3684)
[Bug #12485]