nearly_equals?seems to be the desired behavior. I'll have to inspect it to see if it is semantically equivalent with what I need.
=~for the language's Float type. I was hoping to not monkey patch the whole language, if that is what this is doing, and only introduce this overload when used in my specific module.
=~of 2 floats.
struct FloatWrapper @value : Float64 forward_missing_to @value def initialize(@value : Float64); end def special_method end end
(a : Float64, b : Float64, c : Float64, d : Float64)more concise?
# src/origin/common.cr require "math" module Origin def foo(x, y, rel_tol, abs_tol) (x - y).abs <= Math.max(abs_tol, rel_tol * Math.max(x.abs, y.abs)) end end
Can someone tell me what I am doing wrong here?
# src/origin.cr require "./origin/*" Origin.foo 1.2, 3.4, 1e-7, 1e-7 # Error: undefined method 'foo' for Origin:Module
class A include Origin end A.new.foo