# File lib/core/facets/numeric/approx.rb, line 23 def close?(number, epsilon=0.01) return(self == number) if epsilon.zero? a, b = self.to_f, number.to_f if a.zero? or b.zero? ## There's no scale, so we can only go on difference. (a - b).abs < @epsilon else ## We go by ratio. The ratio of two equal numbers is one, so the ratio ## of two practically-equal floats will be very nearly one. (a/b - 1).abs < epsilon end end