Revert experimental rounding that does not work on i686.

https://bugs.ruby-lang.org/issues/13980
This commit is contained in:
Pavel Valena 2017-10-06 01:47:48 +02:00
parent 76119c738a
commit a46567bd73
2 changed files with 85 additions and 0 deletions

View File

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

View File

@ -126,6 +126,9 @@ Patch7: ruby-2.2.3-Generate-preludes-using-miniruby.patch
# hardening features of glibc (rhbz#1361037). # hardening features of glibc (rhbz#1361037).
# https://bugs.ruby-lang.org/issues/12666 # https://bugs.ruby-lang.org/issues/12666
Patch9: ruby-2.3.1-Rely-on-ldd-to-detect-glibc.patch Patch9: ruby-2.3.1-Rely-on-ldd-to-detect-glibc.patch
# Revert experimental rounding that does not work on i686:
# https://bugs.ruby-lang.org/issues/13980
Patch10: ruby-2.3.5-Revert-experimental-rounding-on-i686.patch
# Do not freeze strings in generated .gemspec. This causes regressions # Do not freeze strings in generated .gemspec. This causes regressions
# and FTBFS in Fedora packages. This is revert of: # and FTBFS in Fedora packages. This is revert of:
# https://github.com/rubygems/rubygems/commit/8eda3272d28010c768a05620de776e5a8195c1ae # https://github.com/rubygems/rubygems/commit/8eda3272d28010c768a05620de776e5a8195c1ae
@ -479,6 +482,7 @@ rm -rf ext/fiddle/libffi*
%patch6 -p1 %patch6 -p1
%patch7 -p1 %patch7 -p1
%patch9 -p1 %patch9 -p1
%patch10 -p1
%patch100 -p1 %patch100 -p1
# Provide an example of usage of the tapset: # Provide an example of usage of the tapset: