diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-28 05:11:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-28 05:11:44 +0000 |
commit | 99431e7355cadb97049d54bcffe5aeb2ba1c8a47 (patch) | |
tree | dd2dde25eb59bf16ec35daee60446b3ce4267e27 /test | |
parent | a4a551f85658c90de5723b9d0f7e06c87a0e6378 (diff) | |
download | ruby-99431e7355cadb97049d54bcffe5aeb2ba1c8a47.tar.gz |
numeric.c: float overflow
* numeric.c (ruby_num_interval_step_size): get rid of float
conversion overflow.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_numeric.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/ruby/test_numeric.rb b/test/ruby/test_numeric.rb index 0c9c38610c..7265c0ed46 100644 --- a/test/ruby/test_numeric.rb +++ b/test/ruby/test_numeric.rb @@ -271,6 +271,14 @@ class TestNumeric < Test::Unit::TestCase assert_equal(bignum*2+1, (-bignum).step(bignum, 1).size) assert_equal(bignum*2, (-bignum).step(bignum-1, 1).size) + assert_equal(10+1, (0.0).step(10.0, 1.0).size) + + i, bigflo = 1, bignum.to_f + i <<= 1 until (bigflo - i).to_i < bignum + bigflo -= i >> 1 + assert_equal(bigflo.to_i, (0.0).step(bigflo-1.0, 1.0).size) + assert_operator((0.0).step(bignum.to_f, 1.0).size, :>=, bignum) # may loose precision + assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 10] assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, to: 10] assert_step [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, to: 10, by: nil] |