ruby-changes:47394
From: nagachika <ko1@a...>
Date: Sat, 5 Aug 2017 10:45:46 +0900 (JST)
Subject: [ruby-changes:47394] nagachika:r59510 (ruby_2_4): merge revision(s) 58523: [Backport #13528]
nagachika 2017-08-05 10:45:39 +0900 (Sat, 05 Aug 2017) New Revision: 59510 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59510 Log: merge revision(s) 58523: [Backport #13528] rational.c: canonicalization case * rational.c (float_numerator, float_denominator): fix for canonicalization case where `Float#to_r` could return an Integer not a Rational. although mathn.rb has been removed in the trunk, fix for the backport purpose. [ruby-core:80942] [Bug #13528] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/rational.c branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59509) +++ ruby_2_4/version.h (revision 59510) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-08-05" -#define RUBY_PATCHLEVEL 173 +#define RUBY_PATCHLEVEL 174 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 8 Index: ruby_2_4/rational.c =================================================================== --- ruby_2_4/rational.c (revision 59509) +++ ruby_2_4/rational.c (revision 59510) @@ -2022,9 +2022,14 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_4/rational.c#L2022 float_numerator(VALUE self) { double d = RFLOAT_VALUE(self); + VALUE r; if (isinf(d) || isnan(d)) return self; - return nurat_numerator(float_to_r(self)); + r = float_to_r(self); + if (canonicalization && k_integer_p(r)) { + return r; + } + return nurat_numerator(r); } /* @@ -2040,9 +2045,14 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_4/rational.c#L2045 float_denominator(VALUE self) { double d = RFLOAT_VALUE(self); + VALUE r; if (isinf(d) || isnan(d)) return INT2FIX(1); - return nurat_denominator(float_to_r(self)); + r = float_to_r(self); + if (canonicalization && k_integer_p(r)) { + return ONE; + } + return nurat_denominator(r); } /* Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 59509) +++ ruby_2_4 (revision 59510) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r58523 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/