diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-07-07 07:37:55 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-07-07 07:37:55 +0000 |
commit | 0229f70039a4eab72d3a007e4fde2af8935d750b (patch) | |
tree | 0ab24af61bc3fe18bd6fccc658fd2350a03c5984 /test/ruby/test_float.rb | |
parent | 5d339a32e88dce014a315d7ce791332d6814c693 (diff) | |
download | ruby-0229f70039a4eab72d3a007e4fde2af8935d750b.tar.gz |
numeric.c: round nearly middle value
* 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
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_float.rb')
-rw-r--r-- | test/ruby/test_float.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 06b1d85242..2684cd8eab 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -447,6 +447,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 def test_floor_with_precision |