Search code examples
ruby

How to compare Floats with delta?


Is there in Ruby some functionality/syntax to compare two floats with delta? Something similar to assert_in_delta(expected_float, actual_float, delta) from test/unit but returning Boolean?


Solution

  • (expected_float - actual_float).abs <= delta