jackorp / rpms / ruby

Forked from rpms/ruby 3 years ago
Clone
a46567b
From 2dfde7e8586cf35318b6053410dba74fe9f06f8d Mon Sep 17 00:00:00 2001
a46567b
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
a46567b
Date: Sun, 30 Apr 2017 13:27:17 +0000
a46567b
Subject: [PATCH] REVERTED: merge revision(s) 55604,55612: [Backport #13138]
a46567b
a46567b
  * numeric.c (flo_round): [EXPERIMENTAL] adjust the case that the
a46567b
    receiver is close to the exact but unrepresentable middle value
a46567b
    of two values in the given precision.
a46567b
    http://d.hatena.ne.jp/hnw/20160702
a46567b
a46567b
  numeric.c: round as double
a46567b
a46567b
  * numeric.c (flo_round): compare as double, not long double with
a46567b
    i387.
a46567b
a46567b
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
a46567b
---
a46567b
 ChangeLog               |    7 -------
a46567b
 test/ruby/test_float.rb |    5 -----
a46567b
 2 files changed, 12 deletions(-)
a46567b
a46567b
diff --git a/ChangeLog b/ChangeLog
a46567b
--- a/ChangeLog
a46567b
+++ b/ChangeLog
a46567b
@@ -604,13 +604,6 @@
a46567b
 	  to check if no library is required, instead of AC_CHECK_LIB.
a46567b
 	  [ruby-core:79368] [Bug #13175]
a46567b
 
a46567b
-Sun Apr 30 22:24:25 2017  Nobuyoshi Nakada  <nobu@ruby-lang.org>
a46567b
-
a46567b
-	* numeric.c (flo_round): [EXPERIMENTAL] adjust the case that the
a46567b
-	  receiver is close to the exact but unrepresentable middle value
a46567b
-	  of two values in the given precision.
a46567b
-	  http://d.hatena.ne.jp/hnw/20160702
a46567b
-
a46567b
 Sun Apr  9 22:21:23 2017  NAKAMURA Usaku  <usa@ruby-lang.org>
a46567b
 
a46567b
 	thread.c: rb_thread_fd_close [ci skip]
a46567b
diff --git a/numeric.c b/numeric.c
a46567b
+-- a/numeric.c
a46567b
@@ -1786,7 +1786,7 @@
a46567b
 flo_round(int argc, VALUE *argv, VALUE num)
a46567b
 {
a46567b
     VALUE nd;
a46567b
+    double number, f;
a46567b
-    double number, f, x;
a46567b
     int ndigits = 0;
a46567b
     int binexp;
a46567b
     enum {float_dig = DBL_DIG+2};
a46567b
@@ -1828,14 +1821,8 @@
a46567b
 	return DBL2NUM(0);
a46567b
     }
a46567b
     f = pow(10, ndigits);
a46567b
+    return DBL2NUM(round(number * f) / f);
a46567b
+}
a46567b
-    x = round(number * f);
a46567b
-    if (x > 0) {
a46567b
-	if ((double)((x + 0.5) / f) <= number) x += 1;
a46567b
-    }
a46567b
-    else {
a46567b
-	if ((double)((x - 0.5) / f) >= number) x -= 1;
a46567b
-    }
a46567b
-    return DBL2NUM(x / f);}
a46567b
 
a46567b
 /*
a46567b
  *  call-seq:
a46567b
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb
a46567b
--- a/test/ruby/test_float.rb
a46567b
+++ b/test/ruby/test_float.rb
a46567b
@@ -444,11 +444,6 @@
a46567b
     assert_raise(TypeError) {1.0.round(nil)}
a46567b
     def (prec = Object.new).to_int; 2; end
a46567b
     assert_equal(1.0, 0.998.round(prec))
a46567b
-
a46567b
-    assert_equal(+5.02, +5.015.round(2))
a46567b
-    assert_equal(-5.02, -5.015.round(2))
a46567b
-    assert_equal(+1.26, +1.255.round(2))
a46567b
-    assert_equal(-1.26, -1.255.round(2))
a46567b
   end
a46567b
 
a46567b
   VS = [