Skip to content

Commit

Permalink
Corrected faulty floating point range check that would always fail.
Browse files Browse the repository at this point in the history
Included allowance for FP round off error.
  • Loading branch information
brentr committed Oct 12, 2011
1 parent 1b4268d commit 92c4f08
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/ruby/test_range.rb
Expand Up @@ -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

0 comments on commit 92c4f08

Please sign in to comment.