From 2dfde7e8586cf35318b6053410dba74fe9f06f8d Mon Sep 17 00:00:00 2001 From: usa Date: Sun, 30 Apr 2017 13:27:17 +0000 Subject: 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 --- test/ruby/test_float.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 3afd26d0b4..7d979a824f 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -442,6 +442,11 @@ class TestFloat < Test::Unit::TestCase 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 = [ -- cgit v1.2.3