Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Corrected faulty floating point range check that would always fail.

Included allowance for FP round off error.
  • Loading branch information...
commit 92c4f087a11699f23cdf76675f4ab5903028ca71 1 parent 1b4268d
@brentr authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 test/ruby/test_range.rb
View
4 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
Please sign in to comment.
Something went wrong with that request. Please try again.