From 92c4f087a11699f23cdf76675f4ab5903028ca71 Mon Sep 17 00:00:00 2001 From: Brent Roman Date: Tue, 11 Oct 2011 17:10:59 -0700 Subject: [PATCH] Corrected faulty floating point range check that would always fail. Included allowance for FP round off error. --- test/ruby/test_range.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 14f59e2ff5..9d66b56e89 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -20,7 +20,9 @@ def test_step_ruby_core_35753 assert_equal(5, (1.1...6).step.to_a.size) assert_equal(5, (1...6).step(1.1).to_a.size) assert_equal(3, (1.0...6.3).step(1.8).to_a.size) - assert_equal(3, (1.0...6.4).step(1.8).to_a.size) + #binary floating point cannot represent 0.1 decimal exactly + #Use BigDecimal if you want an exact representation of 0.1 ! + assert_equal(4, (1.0...6.4000000000001).step(1.8).to_a.size) assert_equal(4, (1.0...6.5).step(1.8).to_a.size) end end